mine.js 4.5 KB

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