user.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. var app = getApp();
  2. var wxh = require('../../utils/wxh.js');
  3. // pages/user/user.js
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. url: app.globalData.urlImages,
  10. userinfo:[],
  11. orderStatusNum:[],
  12. coupon:'',
  13. collect:''
  14. },
  15. setTouchMove: function (e) {
  16. var that = this;
  17. wxh.home(that, e);
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. app.setBarColor();
  24. app.setUserInfo();
  25. var header = {
  26. 'content-type': 'application/x-www-form-urlencoded',
  27. };
  28. var that = this;
  29. wx.request({
  30. url: app.globalData.url + '/routine/auth_api/my?uid=' + app.globalData.uid,
  31. method: 'POST',
  32. header: header,
  33. success: function (res) {
  34. that.setData({
  35. userinfo: res.data.data,
  36. orderStatusNum: res.data.data.orderStatusNum
  37. })
  38. }
  39. });
  40. },
  41. goNotification:function(){
  42. wx.navigateTo({
  43. url: '/pages/news-list/news-list',
  44. })
  45. },
  46. onShow: function () {
  47. var header = {
  48. 'content-type': 'application/x-www-form-urlencoded',
  49. };
  50. var that = this;
  51. wx.request({
  52. url: app.globalData.url + '/routine/auth_api/my?uid=' + app.globalData.uid,
  53. method: 'POST',
  54. header: header,
  55. success: function (res) {
  56. that.setData({
  57. userinfo: res.data.data
  58. })
  59. }
  60. });
  61. },
  62. /**
  63. * 生命周期函数--我的余额
  64. */
  65. money:function(){
  66. wx.navigateTo({
  67. url: '/pages/main/main?now=' + this.data.userinfo.now_money + '&uid='+app.globalData.uid,
  68. success: function (res) { },
  69. fail: function (res) { },
  70. complete: function (res) { },
  71. })
  72. },
  73. /**
  74. * 生命周期函数--我的积分
  75. */
  76. integral: function () {
  77. wx.navigateTo({
  78. url: '/pages/integral-con/integral-con?inte=' + this.data.userinfo.integral + '&uid=' + app.globalData.uid,
  79. success: function (res) { },
  80. fail: function (res) { },
  81. complete: function (res) { },
  82. })
  83. },
  84. /**
  85. * 生命周期函数--我的优惠卷
  86. */
  87. coupons: function () {
  88. wx.navigateTo({
  89. url: '/pages/coupon/coupon',
  90. success: function (res) { },
  91. fail: function (res) { },
  92. complete: function (res) { },
  93. })
  94. },
  95. /**
  96. * 生命周期函数--我的收藏
  97. */
  98. collects: function () {
  99. wx.navigateTo({
  100. url: '/pages/collect/collect',
  101. })
  102. },
  103. /**
  104. * 生命周期函数--我的推广人
  105. */
  106. extension:function(){
  107. wx.navigateTo({
  108. url: '/pages/feree/feree',
  109. success: function (res) { },
  110. fail: function (res) { },
  111. complete: function (res) { },
  112. })
  113. },
  114. /**
  115. * 生命周期函数--我的推广
  116. */
  117. myextension: function () {
  118. wx.navigateTo({
  119. url: '/pages/extension/extension',
  120. success: function (res) { },
  121. fail: function (res) { },
  122. complete: function (res) { },
  123. })
  124. },
  125. getPhoneNumber: function (res){
  126. var that = this;
  127. if (res.detail.errMsg == "getPhoneNumber:ok"){
  128. var pdata = {};
  129. pdata.iv = encodeURI(res.detail.iv);
  130. pdata.encryptedData = res.detail.encryptedData;
  131. pdata.session_key = wx.getStorageSync('session_key');//获取上一步获取的session_key
  132. wx.request({
  133. url: app.globalData.url + '/routine/auth_api/bind_mobile?uid=' + app.globalData.uid,
  134. method: 'post',
  135. dataType  : 'json',
  136. data: {
  137. info: pdata
  138. },
  139. success: function (res) {
  140. if(res.data.code == 200){
  141. wx.showToast({
  142. title: '绑定成功',
  143. icon: 'success',
  144. duration: 2000
  145. })
  146. that.setData({
  147. ['userinfo.phone'] : true
  148. })
  149. }else{
  150. wx.showToast({
  151. title: '绑定失败',
  152. icon: 'none',
  153. duration: 2000
  154. })
  155. }
  156. },
  157. })
  158. } else {
  159. wx.showToast({
  160. title: '取消授权',
  161. icon: 'none',
  162. duration: 2000
  163. })
  164. }
  165. }
  166. /**
  167. * 生命周期函数--我的砍价
  168. */
  169. // cut_down_the_price:function(){
  170. // wx.navigateTo({
  171. // url: '../../pages/feree/feree',
  172. // success: function (res) { },
  173. // fail: function (res) { },
  174. // complete: function (res) { },
  175. // })
  176. // }
  177. })