mine.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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://yuesuo.yueguanjia.com/MiniProgram/images/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. console.log(res)
  89. if (res != "") {
  90. _this.setData({
  91. dcshow: true,
  92. phoneauth: true,
  93. wv_register_count: res.wv_register_count,
  94. wv_contract_count: res.wv_contract_count,
  95. wv_finish_count: res.wv_finish_count,
  96. wv_extract_count: res.wv_extract_count,
  97. wv_grade: res.wv_gradeid,
  98. wv_qrcode: res.wv_qrcode,
  99. wv_account_number: res.wv_account_number,
  100. wv_account_name: res.wv_account_name
  101. })
  102. } else {
  103. _this.setData({
  104. dcshow: false,
  105. phoneauth: true
  106. })
  107. }
  108. })
  109. } else {
  110. this.setData({
  111. dcshow: false,
  112. phoneauth: false
  113. })
  114. }
  115. },
  116. onLoad: function() {
  117. this.setData({
  118. navH: app.globalData.navHeight
  119. })
  120. },
  121. onShow: function() {
  122. const _this = this;
  123. wx.checkSession({
  124. success(res) {
  125. console.log(res)
  126. app.setUserInfo().then(res => {
  127. _this.init()
  128. });
  129. },
  130. fail() {
  131. // session_key 已经失效,需要重新执行登录流程
  132. console.log('checkfail,')
  133. }
  134. })
  135. },
  136. getUserInfo: function(e) {
  137. app.globalData.userInfo = e.detail.userInfo
  138. this.setData({
  139. userInfo: e.detail.userInfo,
  140. hasUserInfo: true
  141. })
  142. },
  143. hrefEq: function(e) {
  144. app.checkSession().then(res => {
  145. wx.navigateTo({
  146. url: '/pages/mine/myeq/myeq'
  147. })
  148. });
  149. },
  150. hrefAboutus: function(e) {
  151. wx.navigateTo({
  152. url: '/pages/mine/aboutus/aboutus'
  153. })
  154. },
  155. hrefAdd: function(e) {
  156. app.checkSession().then(res => {
  157. wx.navigateTo({
  158. url: '/pages/mine/myaddress/myaddress'
  159. })
  160. });
  161. },
  162. hrefCp: function(e) {
  163. app.checkSession().then(res => {
  164. if (app.globalData.userphone == null || app.globalData.userphone == '') {
  165. app.ifAuthorization();
  166. } else {
  167. wx.navigateTo({
  168. url: '/pages/mine/mycoupon/mycoupon'
  169. })
  170. }
  171. });
  172. },
  173. //去授权,不用检测,就是要去那个页面
  174. hrefAuthPhone: function(e) {
  175. wx.navigateTo({
  176. url: '/pages/getphone/getphone?back=mine'
  177. })
  178. },
  179. hrefDc: function(e) {
  180. wx.navigateTo({
  181. url: '/pages/mine/mydc/mydc'
  182. })
  183. },
  184. hrefQrcode: function(e) {
  185. wx.navigateTo({
  186. url: '/pages/mine/myqrcode/myqrcode?para=' + this.data.wv_qrcode
  187. })
  188. },
  189. hrefOrder: function(e) {
  190. if (app.globalData.userphone == null || app.globalData.userphone == '') {
  191. app.ifAuthorization();
  192. } else {
  193. app.checkSession().then(res => {
  194. wx.navigateTo({
  195. url: '/pages/mine/myorder/myorder'
  196. })
  197. });
  198. }
  199. },
  200. review: function() {
  201. wx.navigateTo({
  202. url: '/pages/promotion/promotionhref?para=https://tizhi.zhiyi365.com/default.aspx'
  203. })
  204. },
  205. calling: function() {
  206. wx.makePhoneCall({
  207. phoneNumber: '400-002-2699',
  208. success: function() {
  209. },
  210. fail: function() {
  211. }
  212. })
  213. },
  214. tologin() {
  215. app.checkSession()
  216. },
  217. // hrefMyInfo: function() {
  218. // wx.navigateTo({
  219. // url: '/pages/mine/myinfo/myinfo?accountnumber=' + this.data.wv_account_number + '&wv_account_name=' + this.data
  220. // .wv_account_name
  221. // })
  222. // },
  223. selectlife() {
  224. app.checkSession().then(res => {
  225. wx.navigateTo({
  226. url: '/pages/select/select'
  227. })
  228. });
  229. },
  230. })