mine.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // index.js
  2. var app = getApp();
  3. let host = app.globalData.servsers; // 请求的url
  4. Page({
  5. data: {
  6. userId : '',
  7. userInfo: {},
  8. phone:'',
  9. orderList:{
  10. label:'我的采购订单',
  11. summary:"全部",
  12. state:"0",
  13. icon:"icon-left",
  14. data:[
  15. {
  16. label:"待付款",
  17. state:"1",
  18. icon:"icon-icon-test",
  19. num:0,
  20. },
  21. {
  22. label: "待发货",
  23. state: "3",
  24. icon: "icon-daifahuo1",
  25. num: 0,
  26. },
  27. {
  28. label: "待收货",
  29. state: "4",
  30. icon: "icon-daishouhuo",
  31. num: 0,
  32. }
  33. ]
  34. },
  35. madeList: {
  36. label: '我的定制订单',
  37. summary: "全部",
  38. state: "",
  39. icon: "icon-left",
  40. data: [
  41. {
  42. label: "待付款",
  43. state: "0",
  44. icon: "icon-icon-test",
  45. num: 0,
  46. },
  47. {
  48. label: "待发货",
  49. state: "2",
  50. icon: "icon-daifahuo1",
  51. num: 0,
  52. },
  53. {
  54. label: "待收货",
  55. state: "3",
  56. icon: "icon-daishouhuo",
  57. num: 0,
  58. }
  59. ]
  60. },
  61. channelName:null, // 判断渠道是否登陆了,默认没有登陆
  62. },
  63. onLoad: function () {
  64. var that = this;
  65. var openid = getApp().globalData.openid;
  66. var un_id = getApp().globalData.un_id;
  67. var host = getApp().globalData.servsers;
  68. wx.showNavigationBarLoading();
  69. wx.request({
  70. url: host + "phoneapi/phoneall",
  71. data: {},
  72. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  73. header: {
  74. 'Accept': 'application/json'
  75. },
  76. success: function (res) {
  77. that.setData({
  78. phone: res.data.rows[0].phone,
  79. });
  80. if (res == null || res.data == null) {
  81. console.error('网络请求失败');
  82. return;
  83. }
  84. wx:wx.hideNavigationBarLoading(
  85. that.setData({
  86. hidden : ''
  87. })
  88. )
  89. }
  90. });
  91. that.setData({
  92. userInfo: getApp().globalData.userInfo,
  93. userId: getApp().globalData.un_id
  94. })
  95. console.log(getApp().globalData.userInfo)
  96. },
  97. //重新加载
  98. onShow: function () {
  99. var that = this;
  100. var host = getApp().globalData.servsers;
  101. var un_id = getApp().globalData.un_id;
  102. var openid = getApp().globalData.openid;
  103. var userInfo = getApp().globalData.userInfo;
  104. var userRole = getApp().globalData.userRole;
  105. // if ((un_id == undefined || un_id == '' || un_id == null) || (openid == undefined || openid == '' || openid == null)) {
  106. // wx.navigateTo({
  107. // url: '/pages/authorize/authorize?link=mine',
  108. // })
  109. // } else {
  110. that.getPhone(that)
  111. userInfo = getApp().globalData.userInfo;
  112. //查询用户身份
  113. // getApp().getUserRole(un_id);//获取用户角色
  114. // userRole = getApp().globalData.userRole;
  115. // }
  116. that.setData({
  117. userInfo: userInfo,
  118. userId: un_id,
  119. userRole: userRole,
  120. channelName: wx.getStorageSync('channelName') ? wx.getStorageSync('channelName') : null
  121. })
  122. },
  123. orderList(e){
  124. console.log(e,"orderList")
  125. let state = e.currentTarget.dataset.state
  126. wx.navigateTo({
  127. url: '/pages/orderList/orderList?state='+state,
  128. })
  129. },
  130. madeList(e) {
  131. let state = e.currentTarget.dataset.state;
  132. wx.navigateTo({
  133. url: '/customized/pages/order/order?state=' + state,
  134. })
  135. },
  136. bindPhone(){
  137. wx.navigateTo({
  138. url: '/pages/bindingPhone/bindingPhone',
  139. })
  140. },
  141. getPhone(that){
  142. console.log("获取手机号")
  143. wx.request({
  144. url:host+ '/userapi/userGetPhone',
  145. method:'get',
  146. data:{
  147. user_id: getApp().globalData.un_id
  148. },
  149. success(res){
  150. var tel = res.data.result
  151. tel = "" + tel;
  152. var reg = /(\d{3})\d{4}(\d{4})/;
  153. var tel1 = tel.replace(reg, "$1****$2")
  154. console.log(tel1)
  155. that.setData({
  156. 'userInfo.phone':res.data.result,
  157. tel:tel1
  158. })
  159. }
  160. })
  161. },
  162. outChann(){ // 退出渠道
  163. wx.removeStorageSync('channelIdObj');
  164. this.setData({
  165. channelName:null
  166. })
  167. wx.removeStorageSync('channelName')
  168. },
  169. channelInfo(){
  170. if (wx.getStorageSync('channelIdObj').channelAccountId){
  171. wx.navigateTo({
  172. url: '/pages/channelInfor/channelInfor',
  173. })
  174. } else {
  175. wx.navigateTo({
  176. url: '/pages/login/login?url=/pages/channelInfor/channelInfor',
  177. })
  178. }
  179. }
  180. })