Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

personalCenter.js 6.8KB

il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. // pages/personalCenter/personalCenter.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. myTicketArrows: true,
  9. historyTicketArrows: false,
  10. getUser:false,
  11. getUserArr: [],//用户信息
  12. userChuan:[],
  13. userPhone:"",//用户手机号
  14. mydeg: 0,
  15. historydeg: -90,
  16. pageNum:1,
  17. pageCount:5,
  18. historyArr: [],//优惠券使用记录列表
  19. getHistory: [],//每次接口拉取的数据
  20. getHistoryArr: [],//全部使用数据
  21. myTicketArr: [],//我的优惠券列表
  22. headerImg:"../images/headerImg.png",//默认头像
  23. userName:"",//昵称
  24. noUser:false,
  25. topNum:0,
  26. showCode:false,//显示二维码
  27. codeUrl:""//身份码地址
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad: function (options) {
  33. },
  34. getIDCode:function(){//获取身份码
  35. app.wxRequest(app.globalData.httpUrl + 'front/user/usercode', {}, e => {
  36. if (e.code == 202) {
  37. this.setData({
  38. codeUrl: e.data.user_code_url
  39. })
  40. }
  41. setTimeout(()=>{
  42. this.getIDCode()
  43. },10000)
  44. console.log(this.data.codeUrl)
  45. }, this)
  46. },
  47. getToRsgisterFn:function(){//未注册点击跳到注册页
  48. var state = wx.getStorageSync('state');
  49. if(state==0){
  50. wx.navigateTo({
  51. url: '/pages/register/register',
  52. })
  53. }
  54. },
  55. myTicket:function(){//获取用户待使用代金券、菜品券数量
  56. app.wxRequest(app.globalData.httpUrl + 'front/buy/typenum', {}, e => {
  57. console.log(e)
  58. if (e.code == 200) {
  59. this.setData({
  60. myTicketArr: e.data
  61. })
  62. }
  63. }, this)
  64. },
  65. /**
  66. * 生命周期函数--监听页面初次渲染完成
  67. */
  68. onReady: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面显示
  72. */
  73. onShow: function () {
  74. this.setData({
  75. topNum:0
  76. })
  77. this.data.pageNum = 1;
  78. this.data.getHistoryArr = [];
  79. if (app.globalData.openId) {
  80. this.myTicket();
  81. } else {
  82. app.globalData.openidSuccessFuc = this.myTicket;
  83. }
  84. if (!this.data.getUser) {
  85. var state = wx.getStorageSync('state');
  86. if (state == 1) {//已注册
  87. var userInfo = wx.getStorageSync('userInfo');
  88. var phone = wx.getStorageSync('user_phone');
  89. if (!userInfo.avatarUrl){
  90. this.setData({
  91. headerImg: "../images/headerImg.png",
  92. userName: userInfo.nickName,
  93. userPhone: phone,
  94. getUserArr:userInfo,
  95. getUser: true
  96. })
  97. console.log(this.data.getUserArr)
  98. }else{
  99. this.setData({
  100. headerImg: userInfo.avatarUrl,
  101. userName: userInfo.nickName,
  102. userPhone: phone,
  103. getUserArr:userInfo,
  104. getUser: true
  105. })
  106. }
  107. console.log(wx.getStorageSync('noUser'))
  108. if (wx.getStorageSync('noUser')==0) {
  109. this.setData({
  110. noUser: true
  111. })
  112. } else if (wx.getStorageSync('noUser') == 1) {
  113. this.setData({
  114. noUser: false
  115. })
  116. }
  117. } else if (state == 0) {//未注册
  118. console.log(app.globalData.noUser)
  119. this.setData({
  120. getUser: false,
  121. noUser: false
  122. })
  123. } else if (state == -1) {
  124. app.globalData.userInfoBackFn = res => {//等待结果
  125. console.log(res)
  126. if (res) {
  127. var userInfo = wx.getStorageSync('userInfo');
  128. var phone = wx.getStorageSync('user_phone');
  129. if (!userInfo.avatarUrl) {
  130. this.setData({
  131. headerImg: "../images/headerImg.png",
  132. userName: userInfo.nickName,
  133. userPhone: phone,
  134. getUserArr:userInfo,
  135. getUser: true
  136. })
  137. } else {
  138. this.setData({
  139. headerImg: userInfo.avatarUrl,
  140. userName: userInfo.nickName,
  141. userPhone: phone,
  142. getUserArr:userInfo,
  143. getUser: true
  144. })
  145. }
  146. if (wx.getStorageSync('noUser') == 0) {
  147. this.setData({
  148. noUser: true
  149. })
  150. } else if (wx.getStorageSync('noUser') == 1) {
  151. this.setData({
  152. noUser: false
  153. })
  154. }
  155. } else {
  156. this.setData({
  157. getUser: false,
  158. noUser: false
  159. })
  160. }
  161. }
  162. }
  163. }
  164. },
  165. /**
  166. * 生命周期函数--监听页面隐藏
  167. */
  168. onHide: function () {
  169. },
  170. /**
  171. * 生命周期函数--监听页面卸载
  172. */
  173. onUnload: function () {
  174. },
  175. /**
  176. * 页面相关事件处理函数--监听用户下拉动作
  177. */
  178. onPullDownRefresh: function () {
  179. },
  180. /**
  181. * 页面上拉触底事件的处理函数
  182. */
  183. onReachBottom: function () {
  184. },
  185. /**
  186. * 用户点击右上角分享
  187. */
  188. onShareAppMessage: function () {
  189. return {
  190. title: "老门框爆肚会员",
  191. success: res => {
  192. console.log(res, "转发成功")
  193. },
  194. }
  195. },
  196. lookMyTicket:function(e){
  197. var index = e.currentTarget.dataset.index;
  198. wx.navigateTo({
  199. url: '../myReplace/myReplace?index='+index
  200. })
  201. },
  202. lookTicket: function (e) {//查看优惠券
  203. console.log(e)
  204. var id = e.currentTarget.dataset.id;
  205. wx.navigateTo({
  206. url: '../TicketDetails/TicketDetails?id=' + id,
  207. })
  208. },
  209. giveTicket:function(e){//赠送优惠券
  210. var id = e.target.dataset.id;
  211. wx.navigateTo({
  212. url: '../givePage/givePage?id=' + id,
  213. })
  214. },
  215. getUser:function(e){//点击登陆获取用户信息
  216. console.log(e)
  217. if (e.detail.userInfo) {
  218. this.data.userChuan = e.detail.userInfo;
  219. wx.setStorageSync('noUser', 1);
  220. wx.setStorageSync("userInfo", e.detail.userInfo)
  221. this.setData({
  222. headerImg: e.detail.userInfo.avatarUrl,
  223. userName: e.detail.userInfo.nickName,
  224. getUser: true,
  225. noUser: false
  226. })
  227. this.submitUser();
  228. }
  229. },
  230. submitUser: function () {//提交用户信息
  231. if (this.data.userChuan) {
  232. var params = {
  233. "province": this.data.userChuan.province,
  234. "language": this.data.userChuan.language,
  235. "city": this.data.userChuan.city,
  236. "gender": this.data.userChuan.gender,
  237. "nickname": this.data.userChuan.nickName,
  238. "headimgurl": this.data.userChuan.avatarUrl,
  239. }
  240. app.wxRequest(app.globalData.httpUrl + 'submit', params, e => {
  241. console.log(e)
  242. if (e.code == 200) {
  243. }
  244. }, this, "POST")
  245. }
  246. },
  247. showFn:function(){//显示二维码
  248. this.getIDCode();
  249. this.setData({
  250. showCode:true
  251. })
  252. },
  253. hiddenCode:function(){//隐藏二维码
  254. this.setData({
  255. showCode:false
  256. })
  257. },
  258. skipScore:function(){//跳转到积分页面
  259. wx.navigateTo({
  260. url:"../addScore/addScore"
  261. })
  262. }
  263. })