mine.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. const app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. load:false,
  8. userInfo: {},
  9. hasUserInfo: false,
  10. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  11. Auctioneer:true,
  12. wxUserInfo: true,
  13. bangding:true,
  14. dataObjs:[],
  15. storestate: '',
  16. userHeadUrl: '../../images/userhead.png',
  17. userName: '',
  18. mobile: '',
  19. shop: true,
  20. deliver: 0,
  21. pay_money: 0,
  22. receive: 0,
  23. balance: 0
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. //show.js
  29. //获取应用实例
  30. modalcnt:function(){
  31. wx.showModal({
  32. title: '提示',
  33. content: '功能敬请期待',
  34. success: function (res) {
  35. if (res.confirm) {
  36. } else if (res.cancel) {
  37. }
  38. }
  39. })
  40. },
  41. //开店认证
  42. shop:function(e){
  43. var _this = this;
  44. var mobile = wx.getStorageSync('persion').persion.mobile;
  45. if (mobile) {
  46. wx.request({
  47. url: app.globalData.prodUrl + 'web-pm/wx/pm/get_shop_info',
  48. header: {
  49. 'ydw-token': wx.getStorageSync('key').ydw_token
  50. },
  51. success: function (data) {
  52. if (data.data.tip.msg == "未认证") {
  53. wx.showModal({
  54. title: '提示',
  55. content: '您未有店铺,点击确定进行注册!',
  56. success: function (res) {
  57. if (res.confirm) {
  58. wx.navigateTo({
  59. url: '../mine/wxml/shopregistration/shopregistration'
  60. })
  61. } else if (res.cancel) {
  62. }
  63. }
  64. })
  65. } else if (data.data.tip.msg == "未审核") {
  66. wx.showModal({
  67. title: '提示',
  68. content: '您的店铺正在审核,请耐心等待1~2个工作日',
  69. success: function (res) {
  70. if (res.confirm) {
  71. } else if (res.cancel) {
  72. }
  73. }
  74. })
  75. } else {
  76. wx.navigateTo({
  77. url: '../mine/wxml/allthesellers/allthesellers?shopkid=' + data.data.shop.kid + '&name=' + data.data.shop.name
  78. })
  79. }
  80. }
  81. })
  82. } else {
  83. wx.showToast({
  84. title: '请您先绑定帐号!',
  85. icon: 'none'
  86. })
  87. }
  88. },
  89. onLoad: function (options) {
  90. let _this = this;
  91. var mobile = wx.getStorageSync('persion').persion.mobile;
  92. if (mobile){
  93. var nmobile = mobile.substr(0, 3) + '****' + mobile.substring(7, 11);
  94. _this.setData({
  95. bangding: false,
  96. mobile: '已绑定:' + nmobile
  97. })
  98. }
  99. if (this.data.hasUserInfo) {
  100. _this.setData({
  101. userInfo: app.globalData.userInfo,
  102. hasUserInfo: true
  103. })
  104. } else if (_this.data.canIUse) {
  105. _this.setData({
  106. userInfo: wx.getStorageSync('persion').persion,
  107. })
  108. } else {
  109. // 在没有 open-type=getUserInfo 版本的兼容处理
  110. wx.getUserProfile({
  111. desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  112. success: (res) => {
  113. app.globalData.userInfo = res.userInfo
  114. this.setData({
  115. userInfo: res.userInfo,
  116. hasUserInfo: true
  117. })
  118. }
  119. })
  120. };
  121. wx.request({
  122. url: app.globalData.prodUrl + 'web-pm/wx/pm/get_shop_info',
  123. header: {
  124. 'ydw-token': wx.getStorageSync('key').ydw_token
  125. },
  126. success: function (data) {
  127. _this.setData({
  128. balance: data.data.balance
  129. })
  130. if (data.data.tip.msg == "未认证") {
  131. _this.setData({
  132. storestate: '立即注册'
  133. })
  134. } else if (data.data.tip.msg == "未审核") {
  135. _this.setData({
  136. storestate: '正在审核'
  137. })
  138. } else if (data.data.tip.msg == "已认证") {
  139. _this.setData({
  140. shopName: data.data.shop.name,
  141. storestate: '进入店铺',
  142. shop: false
  143. })
  144. }
  145. }
  146. });
  147. wx.request({
  148. url: app.globalData.prodUrl + 'web-pm/wx/pm/select_count',
  149. header: {
  150. 'ydw-token': wx.getStorageSync('key').ydw_token
  151. },
  152. method: 'GET',
  153. dataType: 'json',
  154. responseType: 'text',
  155. success: function(data) {
  156. _this.setData({
  157. deliver: data.data.wait_deliver > 99 ? 99 : data.data.wait_deliver,
  158. pay_money: data.data.wait_pay_money > 99 ? 99 : data.data.wait_pay_money,
  159. receive: data.data.wait_receive > 99 ? 99 : data.data.wait_receive
  160. })
  161. },
  162. fail: function(res) {},
  163. complete: function(res) {},
  164. })
  165. },
  166. /**
  167. * 生命周期函数--监听页面初次渲染完成
  168. */
  169. onReady: function () {
  170. },
  171. /**
  172. * 生命周期函数--监听页面显示
  173. */
  174. onShow: function () {
  175. if(this.data.load) {
  176. this.onLoad();
  177. }
  178. },
  179. /**
  180. * 生命周期函数--监听页面隐藏
  181. */
  182. onHide: function () {
  183. this.setData({
  184. load:true
  185. })
  186. },
  187. /**
  188. * 生命周期函数--监听页面卸载
  189. */
  190. onUnload: function () {
  191. },
  192. /**
  193. * 页面相关事件处理函数--监听用户下拉动作
  194. */
  195. onPullDownRefresh: function () {
  196. },
  197. /**
  198. * 页面上拉触底事件的处理函数
  199. */
  200. onReachBottom: function () {
  201. },
  202. /**
  203. * 用户点击右上角分享
  204. */
  205. imgClickShow:function(){
  206. var imgUrl = this.data.userInfo.avatarUrl;
  207. wx.previewImage({
  208. urls:[imgUrl],
  209. success:function(){
  210. }
  211. })
  212. },
  213. userAuthorize: function () {
  214. wx.getSetting({
  215. success: res => {
  216. if (!res.authSetting['scope.userInfo']) {
  217. this.setData({
  218. wxUserInfo: false
  219. });
  220. } else {
  221. this.setData({
  222. wxUserInfo: true
  223. });
  224. }
  225. }
  226. })
  227. },
  228. getUserProfile(e) {
  229. let _this = this
  230. // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
  231. // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
  232. wx.getUserProfile({
  233. desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  234. success: (res) => {
  235. app.globalData.userInfo =res.userInfo
  236. _this.setData({
  237. userInfo: res.userInfo,
  238. hasUserInfo: true
  239. })
  240. wx.request({
  241. url: app.globalData.prodUrl + 'web-pm/wx/pm/update_userinfo',
  242. data: {
  243. userinfo: JSON.stringify(res.userInfo)
  244. },
  245. header: { 'ydw-token': wx.getStorageSync('key').ydw_token },
  246. method: 'GET',
  247. dataType: 'json',
  248. responseType: 'text',
  249. success: function (data) {
  250. wx.setStorageSync('persion', { 'persion': data.data.persion });
  251. },
  252. fail: function (res) { }
  253. })
  254. }
  255. })
  256. },
  257. })