mine.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. channIdState:false, // 判断渠道是否登陆了,默认没有登陆
  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. console.log(wx.getStorageSync('channelIdObj'),"ffffff")
  117. that.setData({
  118. userInfo: userInfo,
  119. userId: un_id,
  120. userRole: userRole,
  121. channIdState: wx.getStorageSync('channelIdObj').channelAccountId ? true : false
  122. })
  123. console.log(that.data.channIdState)
  124. },
  125. orderList(e){
  126. console.log(e,"orderList")
  127. let state = e.currentTarget.dataset.state
  128. wx.navigateTo({
  129. url: '/pages/orderList/orderList?state='+state,
  130. })
  131. },
  132. madeList(e) {
  133. let state = e.currentTarget.dataset.state;
  134. wx.navigateTo({
  135. url: '/customized/pages/order/order?state=' + state,
  136. })
  137. },
  138. bindPhone(){
  139. wx.navigateTo({
  140. url: '/pages/bindingPhone/bindingPhone',
  141. })
  142. },
  143. getPhone(that){
  144. console.log("获取手机号")
  145. wx.request({
  146. url:host+ '/userapi/userGetPhone',
  147. method:'get',
  148. data:{
  149. user_id: getApp().globalData.un_id
  150. },
  151. success(res){
  152. var tel = res.data.result
  153. tel = "" + tel;
  154. var reg = /(\d{3})\d{4}(\d{4})/;
  155. var tel1 = tel.replace(reg, "$1****$2")
  156. console.log(tel1)
  157. that.setData({
  158. 'userInfo.phone':res.data.result,
  159. tel:tel1
  160. })
  161. }
  162. })
  163. },
  164. outChann(){ // 退出渠道
  165. wx.removeStorageSync('channelIdObj');
  166. this.setData({
  167. channIdState:false
  168. })
  169. },
  170. channelInfo(){
  171. if (wx.getStorageSync('channelIdObj').channelAccountId){
  172. wx.navigateTo({
  173. url: '/pages/channelInfor/channelInfor',
  174. })
  175. } else {
  176. wx.navigateTo({
  177. url: '/pages/login/login?url=/pages/channelInfor/channelInfor',
  178. })
  179. }
  180. }
  181. })