mine.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. phoneShow: false,
  33. mask: false
  34. },
  35. //事件处理函数
  36. bindViewTap: function() {
  37. wx.navigateTo({
  38. url: '../logs/logs'
  39. })
  40. },
  41. init() {
  42. const _this = this;
  43. // 判断用户是否设置过孕期
  44. util.getData('/getWXUser', {
  45. xu_openid: app.globalData.openid
  46. })
  47. .then(res => {
  48. // console.log(res);
  49. if (res.xu_content_type && res.xu_content_date) {
  50. _this.setData({
  51. isSetstatus: true
  52. })
  53. // 育儿或孕周内容查询
  54. util.postData('/queryUserContent', {
  55. openid: app.globalData.openid
  56. })
  57. .then(res => {
  58. // console.log(res)
  59. _this.setData({
  60. pushCont: res
  61. })
  62. })
  63. .catch(err => {
  64. console.log(err);
  65. })
  66. }
  67. })
  68. .catch(err => {
  69. console.log(err);
  70. })
  71. //获取用户等级
  72. console.log(app.globalData);
  73. if (app.globalData.usertype == 2) {
  74. this.setData({
  75. nickName: app.globalData.userInfo.nickName,
  76. avatarUrl: app.globalData.userInfo.avatarUrl
  77. })
  78. } else {
  79. this.setData({
  80. // nickName: app.globalData.nickName,
  81. avatarUrl: 'https://yuesuo.yueguanjia.com/MiniProgram/images/head.png'
  82. })
  83. }
  84. //判断是否为介绍人
  85. if (app.globalData.userphone != null && app.globalData.userphone != 'undefined' && app.globalData.userphone !=
  86. ' ' && app.globalData.userphone != '') {
  87. util.getData('/checkDcIntroducers', {
  88. wv_phone: app.globalData.userphone
  89. }).then(res => {
  90. if (res != "") {
  91. _this.setData({
  92. dcshow: true,
  93. phoneauth: true,
  94. wv_register_count: res.wv_register_count,
  95. wv_contract_count: res.wv_contract_count,
  96. wv_finish_count: res.wv_finish_count,
  97. wv_extract_count: res.wv_extract_count,
  98. wv_grade: res.wv_gradeid,
  99. wv_qrcode: res.wv_qrcode,
  100. wv_account_number: res.wv_account_number,
  101. wv_account_name: res.wv_account_name
  102. })
  103. } else {
  104. _this.setData({
  105. dcshow: false,
  106. phoneauth: true
  107. })
  108. }
  109. })
  110. } else {
  111. this.setData({
  112. dcshow: false,
  113. phoneauth: false
  114. })
  115. }
  116. },
  117. onLoad: function() {
  118. this.setData({
  119. navH: app.globalData.navHeight
  120. })
  121. },
  122. onShow: function() {
  123. const _this = this;
  124. wx.checkSession({
  125. success(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. hrefTest () {
  231. wx.showToast({
  232. title: '功能正在建设中……',
  233. icon: 'none',
  234. duration: 1500
  235. })
  236. },
  237. hrefCall () {
  238. this.setData({
  239. mask: true,
  240. phoneShow: true
  241. })
  242. },
  243. hideAllBox() {
  244. this.setData({
  245. //遮罩层隐藏
  246. mask: false
  247. })
  248. },
  249. callPhone1 () {
  250. wx.makePhoneCall({
  251. phoneNumber: '024-25689988'
  252. })
  253. },
  254. callPhone2 () {
  255. wx.makePhoneCall({
  256. phoneNumber: '17609810980'
  257. })
  258. }
  259. })