personal.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. import Navi from '../../utils/navi'
  2. import { getUser } from '../../utils/util'
  3. const menuData = [
  4. [
  5. {
  6. title: '收货地址',
  7. tit: '',
  8. url: '/pages/mine/myaddr/list/index',
  9. type: 'address',
  10. },
  11. {
  12. title: '优惠券',
  13. tit: '',
  14. url: '',
  15. type: 'coupon',
  16. },
  17. {
  18. title: '积分',
  19. tit: '',
  20. url: '',
  21. type: 'point',
  22. },
  23. ],
  24. [
  25. {
  26. title: '购物卡余额查询',
  27. tit: '',
  28. url: '',
  29. type: 'point',
  30. },
  31. {
  32. title: '客服热线',
  33. tit: '',
  34. url: '',
  35. type: 'service',
  36. icon: 'service',
  37. },
  38. {
  39. title: '我要反馈',
  40. tit: '',
  41. url: '',
  42. type: 'help-center',
  43. },
  44. ],
  45. ]
  46. const orderTagInfos = [
  47. {
  48. title: '待付款',
  49. iconName: 'daifukuan',
  50. orderNum: 0,
  51. tabType: 5,
  52. status: 1,
  53. },
  54. {
  55. title: '待发货',
  56. iconName: 'daifahuo',
  57. orderNum: 0,
  58. tabType: 10,
  59. status: 1,
  60. },
  61. {
  62. title: '待收货',
  63. iconName: 'daishouhuo',
  64. orderNum: 0,
  65. tabType: 40,
  66. status: 1,
  67. },
  68. {
  69. title: '待评价',
  70. iconName: 'daipingjia',
  71. orderNum: 0,
  72. tabType: 60,
  73. status: 1,
  74. },
  75. {
  76. title: '退款/售后',
  77. iconName: 'tuikuantuihuo',
  78. orderNum: 0,
  79. tabType: 0,
  80. status: 1,
  81. },
  82. ]
  83. const getDefaultData = () => ({
  84. showMakePhone: false,
  85. userInfo: {
  86. avatarUrl: '',
  87. nickName: '请登录',
  88. phoneNumber: '',
  89. },
  90. menuData,
  91. orderTagInfos,
  92. customerServiceInfo: {},
  93. currAuthStep: 1,
  94. showKefu: true,
  95. versionNo: '',
  96. })
  97. Page({
  98. /**
  99. * 页面的初始数据
  100. */
  101. data: getDefaultData(),
  102. /**
  103. * 生命周期函数--监听页面加载
  104. */
  105. onLoad() {},
  106. /**
  107. * 生命周期函数--监听页面初次渲染完成
  108. */
  109. onReady() {},
  110. /**
  111. * 生命周期函数--监听页面显示
  112. */
  113. onShow() {
  114. this.getUserInfo()
  115. this.getVersionInfo()
  116. this.getTabBar().init()
  117. },
  118. /**
  119. * 生命周期函数--监听页面隐藏
  120. */
  121. onHide() {},
  122. /**
  123. * 生命周期函数--监听页面卸载
  124. */
  125. onUnload() {},
  126. /**
  127. * 页面相关事件处理函数--监听用户下拉动作
  128. */
  129. onPullDownRefresh() {},
  130. /**
  131. * 页面上拉触底事件的处理函数
  132. */
  133. onReachBottom() {},
  134. /**
  135. * 用户点击右上角分享
  136. */
  137. onShareAppMessage() {},
  138. getUserInfo() {
  139. const info = getUser()
  140. if (info != null) {
  141. this.setData({
  142. userInfo: info as any,
  143. })
  144. } else {
  145. this.setData({
  146. userInfo: {
  147. avatarUrl: '',
  148. nickName: '请登录',
  149. phoneNumber: '',
  150. },
  151. })
  152. }
  153. },
  154. getVersionInfo() {
  155. const versionInfo = wx.getAccountInfoSync()
  156. const { version, envVersion = __wxConfig } = versionInfo.miniProgram
  157. this.setData({
  158. versionNo: envVersion === 'release' ? version : envVersion,
  159. })
  160. },
  161. gotoLogin() {
  162. Navi.navigateTo({
  163. url: '/pages/login/index',
  164. })
  165. },
  166. gotoSetting() {
  167. Navi.navigateTo({
  168. url: '/pages/mine/setting/index',
  169. })
  170. },
  171. jumpAllOrder() {
  172. Navi.navigateTo({
  173. url: '/pages/mine/myorder/list/index',
  174. })
  175. },
  176. jumpNav(e: WechatMiniprogram.CustomEvent<{}>) {
  177. console.log('jump', e)
  178. },
  179. onClickCell(
  180. e: WechatMiniprogram.CustomEvent<
  181. {},
  182. {},
  183. {
  184. item: {
  185. title: string
  186. tit: string
  187. url: string
  188. type: string
  189. icon: string
  190. }
  191. }
  192. >,
  193. ) {
  194. const item = e.currentTarget.dataset.item
  195. if (item.url && item.url.length > 0) {
  196. Navi.navigateTo({
  197. url: item.url,
  198. })
  199. }
  200. },
  201. })