mine.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. const app = getApp()
  2. const util = require('../../utils/util.js')
  3. Page({
  4. data: {
  5. pushCont: {
  6. wc_content: ''
  7. },
  8. isSetstatus: false,
  9. isvip: true,
  10. arr: [],
  11. indicatorDots: true,
  12. wv_grade: '',
  13. wv_account_number: '',
  14. wv_account_name: '',
  15. loaddisplay: true,
  16. dcshow: false,
  17. wv_register_count: '',
  18. wv_contract_count: '',
  19. wv_finish_count: '',
  20. wv_extract_count: '',
  21. wv_qrcode: '',
  22. phoneauth: false,
  23. autoplay: true,
  24. interval: 5000,
  25. duration: 2000,
  26. usertype: '',
  27. userInfo: {},
  28. nickName: '登录',
  29. avatarUrl: 'https://api.zhumi.tech/MiniProgram/image/head.png',
  30. hasUserInfo: false,
  31. canIUse: wx.canIUse('button.open-type.getUserInfo')
  32. },
  33. //事件处理函数
  34. bindViewTap: function() {
  35. wx.navigateTo({
  36. url: '../logs/logs'
  37. })
  38. },
  39. init() {
  40. const _this = this;
  41. // 判断用户是否设置过孕期
  42. util.getData('/getWXUser', {
  43. xu_openid: app.globalData.openid
  44. })
  45. .then(res => {
  46. // console.log(res);
  47. if (res.xu_content_type && res.xu_content_date) {
  48. _this.setData({
  49. isSetstatus: true
  50. })
  51. // 育儿或孕周内容查询
  52. util.postData('/queryUserContent', {
  53. openid: app.globalData.openid
  54. })
  55. .then(res => {
  56. // console.log(res)
  57. _this.setData({
  58. pushCont: res
  59. })
  60. })
  61. .catch(err => {
  62. console.log(err);
  63. })
  64. }
  65. })
  66. .catch(err => {
  67. console.log(err);
  68. })
  69. //获取用户等级
  70. console.log(app.globalData);
  71. if (app.globalData.usertype == 2) {
  72. this.setData({
  73. nickName: app.globalData.userInfo.nickName,
  74. avatarUrl: app.globalData.userInfo.avatarUrl
  75. })
  76. } else {
  77. this.setData({
  78. // nickName: app.globalData.nickName,
  79. avatarUrl: 'https://yuesuo.yueguanjia.com/MiniProgram/images/head.png'
  80. })
  81. }
  82. //判断是否为介绍人
  83. if (app.globalData.userphone != null && app.globalData.userphone != 'undefined' && app.globalData.userphone !=
  84. ' ' && app.globalData.userphone != '') {
  85. util.getData('/checkDcIntroducers', {
  86. wv_phone: app.globalData.userphone
  87. }).then(res => {
  88. if (res != "") {
  89. _this.setData({
  90. dcshow: true,
  91. phoneauth: true,
  92. wv_register_count: res.wv_register_count,
  93. wv_contract_count: res.wv_contract_count,
  94. wv_finish_count: res.wv_finish_count,
  95. wv_extract_count: res.wv_extract_count,
  96. wv_grade: res.wv_gradeid,
  97. wv_qrcode: res.wv_qrcode,
  98. wv_account_number: res.wv_account_number,
  99. wv_account_name: res.wv_account_name
  100. })
  101. } else {
  102. _this.setData({
  103. dcshow: false,
  104. phoneauth: true
  105. })
  106. }
  107. })
  108. } else {
  109. this.setData({
  110. dcshow: false,
  111. phoneauth: false
  112. })
  113. }
  114. },
  115. onLoad: function() {
  116. this.setData({
  117. navH: app.globalData.navHeight
  118. })
  119. },
  120. onShow: function() {
  121. const _this = this;
  122. wx.checkSession({
  123. success(res) {
  124. app.setUserInfo().then(res => {
  125. _this.init()
  126. });
  127. },
  128. fail() {
  129. // session_key 已经失效,需要重新执行登录流程
  130. console.log('checkfail,')
  131. }
  132. })
  133. },
  134. getUserInfo: function(e) {
  135. app.globalData.userInfo = e.detail.userInfo
  136. this.setData({
  137. userInfo: e.detail.userInfo,
  138. hasUserInfo: true
  139. })
  140. },
  141. hrefEq: function(e) {
  142. app.checkSession().then(res => {
  143. wx.navigateTo({
  144. url: '/pages/mine/myeq/myeq'
  145. })
  146. });
  147. },
  148. hrefAboutus: function(e) {
  149. wx.navigateTo({
  150. url: '/pages/mine/aboutus/aboutus'
  151. })
  152. },
  153. hrefAdd: function(e) {
  154. app.checkSession().then(res => {
  155. wx.navigateTo({
  156. url: '/pages/mine/myaddress/myaddress'
  157. })
  158. });
  159. },
  160. hrefCp: function(e) {
  161. app.checkSession().then(res => {
  162. if (app.globalData.userphone == null || app.globalData.userphone == '') {
  163. app.ifAuthorization();
  164. } else {
  165. wx.navigateTo({
  166. url: '/pages/mine/mycoupon/mycoupon'
  167. })
  168. }
  169. });
  170. },
  171. //去授权,不用检测,就是要去那个页面
  172. hrefAuthPhone: function(e) {
  173. wx.navigateTo({
  174. url: '/pages/getphone/getphone?back=mine'
  175. })
  176. },
  177. hrefDc: function(e) {
  178. wx.navigateTo({
  179. url: '/pages/mine/mydc/mydc'
  180. })
  181. },
  182. hrefQrcode: function(e) {
  183. wx.navigateTo({
  184. url: '/pages/mine/myqrcode/myqrcode?para=' + this.data.wv_qrcode
  185. })
  186. },
  187. hrefOrder: function(e) {
  188. if (app.globalData.userphone == null || app.globalData.userphone == '') {
  189. app.ifAuthorization();
  190. } else {
  191. app.checkSession().then(res => {
  192. wx.navigateTo({
  193. url: '/pages/mine/myorder/myorder'
  194. })
  195. });
  196. }
  197. },
  198. review: function() {
  199. wx.navigateTo({
  200. url: '/pages/promotion/promotionhref?para=https://tizhi.zhiyi365.com/default.aspx'
  201. })
  202. },
  203. calling: function() {
  204. wx.makePhoneCall({
  205. phoneNumber: '400-002-2699',
  206. success: function() {
  207. },
  208. fail: function() {
  209. }
  210. })
  211. },
  212. tologin() {
  213. app.checkSession()
  214. },
  215. // hrefMyInfo: function() {
  216. // wx.navigateTo({
  217. // url: '/pages/mine/myinfo/myinfo?accountnumber=' + this.data.wv_account_number + '&wv_account_name=' + this.data
  218. // .wv_account_name
  219. // })
  220. // },
  221. selectlife() {
  222. app.checkSession().then(res => {
  223. wx.navigateTo({
  224. url: '/pages/select/select'
  225. })
  226. });
  227. },
  228. })