mine.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. // if ((un_id == undefined || un_id == '' || un_id == null) || (openid == undefined || openid == '' || openid == null)) {
  118. // wx.navigateTo({
  119. // url: '/pages/authorize/authorize?link=mine',
  120. // })
  121. // } else {
  122. that.getPhone(that)
  123. userInfo = getApp().globalData.userInfo;
  124. //查询用户身份
  125. // getApp().getUserRole(un_id);//获取用户角色
  126. // userRole = getApp().globalData.userRole;
  127. // }
  128. that.setData({
  129. userInfo: userInfo,
  130. userId: un_id,
  131. userRole: userRole,
  132. channelName: wx.getStorageSync('channelName') ? wx.getStorageSync('channelName') : null
  133. })
  134. },
  135. orderList(e){
  136. console.log(e,"orderList")
  137. let state = e.currentTarget.dataset.state
  138. wx.navigateTo({
  139. url: '/pages/orderList/orderList?state='+state,
  140. })
  141. },
  142. madeList(e) {
  143. let state = e.currentTarget.dataset.state;
  144. wx.navigateTo({
  145. url: '/customized/pages/order/order?state=' + state,
  146. })
  147. },
  148. bindPhone(){
  149. wx.navigateTo({
  150. url: '/pages/bindingPhone/bindingPhone',
  151. })
  152. },
  153. getPhone(that){
  154. console.log("获取手机号")
  155. wx.request({
  156. url:host+ '/userapi/userGetPhone',
  157. method:'get',
  158. data:{
  159. user_id: getApp().globalData.un_id
  160. },
  161. success(res){
  162. var tel = res.data.result
  163. tel = "" + tel;
  164. var reg = /(\d{3})\d{4}(\d{4})/;
  165. var tel1 = tel.replace(reg, "$1****$2")
  166. console.log(tel1)
  167. that.setData({
  168. 'userInfo.phone':res.data.result,
  169. tel:tel1
  170. })
  171. }
  172. })
  173. },
  174. outChann(){ // 退出渠道
  175. wx.removeStorageSync('channelIdObj');
  176. this.setData({
  177. channelName:null
  178. })
  179. wx.removeStorageSync('channelName')
  180. },
  181. channelInfo(){
  182. if (wx.getStorageSync('channelIdObj').channelAccountId){
  183. wx.navigateTo({
  184. url: '/pages/channelInfor/channelInfor',
  185. })
  186. } else {
  187. wx.navigateTo({
  188. url: '/pages/login/login?url=/pages/channelInfor/channelInfor',
  189. })
  190. }
  191. }
  192. })