mine.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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:"",
  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. },
  62. onLoad: function () {
  63. var that = this;
  64. var openid = getApp().globalData.openid;
  65. var un_id = getApp().globalData.un_id;
  66. var host = getApp().globalData.servsers;
  67. wx.showNavigationBarLoading();
  68. wx.request({
  69. url: host + "phoneapi/phoneall",
  70. data: {},
  71. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  72. header: {
  73. 'Accept': 'application/json'
  74. },
  75. success: function (res) {
  76. that.setData({
  77. phone: res.data.rows[0].phone,
  78. });
  79. if (res == null || res.data == null) {
  80. console.error('网络请求失败');
  81. return;
  82. }
  83. wx:wx.hideNavigationBarLoading(
  84. that.setData({
  85. hidden : ''
  86. })
  87. )
  88. }
  89. });
  90. that.setData({
  91. userInfo: getApp().globalData.userInfo,
  92. userId: getApp().globalData.un_id
  93. })
  94. console.log(getApp().globalData.userInfo)
  95. },
  96. //重新加载
  97. onShow: function () {
  98. var that = this;
  99. var host = getApp().globalData.servsers;
  100. var un_id = getApp().globalData.un_id;
  101. var openid = getApp().globalData.openid;
  102. var userInfo = getApp().globalData.userInfo;
  103. var userRole = getApp().globalData.userRole;
  104. // if ((un_id == undefined || un_id == '' || un_id == null) || (openid == undefined || openid == '' || openid == null)) {
  105. // wx.navigateTo({
  106. // url: '/pages/authorize/authorize?link=mine',
  107. // })
  108. // } else {
  109. that.getPhone(that)
  110. userInfo = getApp().globalData.userInfo;
  111. //查询用户身份
  112. // getApp().getUserRole(un_id);//获取用户角色
  113. // userRole = getApp().globalData.userRole;
  114. // }
  115. that.setData({
  116. userInfo: userInfo,
  117. userId: un_id,
  118. userRole: userRole
  119. })
  120. },
  121. orderList(e){
  122. console.log(e,"orderList")
  123. let state = e.currentTarget.dataset.state
  124. wx.navigateTo({
  125. url: '/pages/orderList/orderList?state='+state,
  126. })
  127. },
  128. madeList(e) {
  129. let state = e.currentTarget.dataset.state;
  130. wx.navigateTo({
  131. url: '/customized/pages/order/order?state=' + state,
  132. })
  133. },
  134. bindPhone(){
  135. wx.navigateTo({
  136. url: '/pages/bindingPhone/bindingPhone',
  137. })
  138. },
  139. getPhone(that){
  140. console.log("获取手机号")
  141. wx.request({
  142. url:host+ '/userapi/userGetPhone',
  143. method:'get',
  144. data:{
  145. user_id: getApp().globalData.un_id
  146. },
  147. success(res){
  148. var tel = res.data.result
  149. tel = "" + tel;
  150. var reg = /(\d{3})\d{4}(\d{4})/;
  151. var tel1 = tel.replace(reg, "$1****$2")
  152. console.log(tel1)
  153. that.setData({
  154. 'userInfo.phone':res.data.result,
  155. tel:tel1
  156. })
  157. }
  158. })
  159. }
  160. })