index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. const app = require('../../utils/util.js');
  2. const tool = require('../../utils/tool.js');
  3. Page({
  4. data: {
  5. currentIndex: 0,
  6. arr: [],
  7. arr1: [],
  8. isInfo: false,
  9. isTargetInfo: false,
  10. letterStatus: true,
  11. lbArr: [{
  12. src: '../../images/lb2.jpg'
  13. }],
  14. userInfo: '',
  15. ysf: {
  16. title: '注册页',
  17. config: ''
  18. }
  19. },
  20. // 轮播
  21. handleChange: function (e) {
  22. this.setData({
  23. currentIndex: e.detail.current
  24. })
  25. },
  26. // 关闭信件
  27. closeLetter() {
  28. console.log('1')
  29. this.setData({
  30. letterStatus: true
  31. })
  32. wx.setStorageSync('letterStatus', true)
  33. },
  34. goShare() {
  35. wx.navigateTo({
  36. url: '/pages/share/share',
  37. })
  38. },
  39. // 跳转活动详情页面
  40. goActive(e) {
  41. if (e.currentTarget.dataset.activestatus != -1) {
  42. let id = e.currentTarget.dataset.id
  43. let openId = e.currentTarget.dataset.openid
  44. wx.navigateTo({
  45. url: '/pages/activeDetail/activeDetail?id=' + id + '&openId=' + openId,
  46. })
  47. } else {
  48. wx.showModal({
  49. title: '活动已经结束啦',
  50. showCancel: false
  51. });
  52. }
  53. },
  54. goActiveDefault() {
  55. wx.navigateTo({
  56. url: '/pages/activeDefaultDetails/activeDefaultDetails',
  57. })
  58. },
  59. // 获取活动列表
  60. getActivies() {
  61. wx.request({
  62. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/actives',
  63. method: "get",
  64. success: (res) => {
  65. console.log(res)
  66. if (res.data.code == 0) {
  67. this.setData({
  68. arr: res.data.actives
  69. })
  70. }
  71. },
  72. complete() {
  73. wx.hideLoading();
  74. }
  75. })
  76. },
  77. goInfo() {
  78. wx.redirectTo({
  79. url: '/pages/personInfo/personInfo',
  80. })
  81. },
  82. goMy() {
  83. wx.redirectTo({
  84. url: '/pages/personal/personal',
  85. })
  86. },
  87. getIntroduce(id) {
  88. wx.request({
  89. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/introduce',
  90. method: "get",
  91. data: {
  92. introduce: id
  93. },
  94. success: (res) => {
  95. console.log(res, '获取推荐人')
  96. }
  97. })
  98. },
  99. getletterStauts() {
  100. console.log(wx.getStorageSync('letterStatus'))
  101. if (wx.getStorageSync('letterStatus') == true) {
  102. console.log('我缓存里有值是1')
  103. this.setData({
  104. letterStatus: true
  105. })
  106. // this.closeLetter();
  107. } else {
  108. console.log('我没有缓存、')
  109. this.setData({
  110. letterStatus: false
  111. })
  112. }
  113. console.log(this.data.letterStatus)
  114. },
  115. getInfos() {
  116. wx.request({
  117. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/info',
  118. method: "get",
  119. success: (res) => {
  120. if (res.data.code == 0) {
  121. let config='ysf.config';
  122. let sex1 = '';
  123. if(res.data.info.sex==0){
  124. sex1='女'
  125. }else{
  126. sex1='男'
  127. }
  128. console.log(sex1)
  129. this.setData({
  130. myInfo: res.data.info,
  131. [config]:JSON.stringify({
  132. "uid": res.data.id, // 用户唯一标识
  133. "level": 1, // vip等级
  134. "data": JSON.stringify([{
  135. "index": 0,
  136. "key": "name",
  137. "label": "姓名",
  138. "value": res.data.info.name
  139. },
  140. {
  141. "index": 1,
  142. "key": "createTime",
  143. "label": "创建时间",
  144. "value": res.data.info.createTime
  145. },
  146. {
  147. "index": 2,
  148. "key": "sex",
  149. "label": "性别",
  150. "value": sex1
  151. },
  152. {
  153. "index": 3,
  154. "key": "tel",
  155. "label": "电话",
  156. "value": res.data.info.tel
  157. }
  158. ])
  159. })
  160. })
  161. console.log(this.data.ysf.config)
  162. }
  163. }
  164. })
  165. },
  166. onLoad(options) {
  167. tool.openidStatus().then(result => {
  168. this.setData({
  169. openid: result[0],
  170. sessionkey: result[1],
  171. })
  172. this.getActivies();
  173. this.getInfos()
  174. })
  175. if (options.id) {
  176. this.getIntroduce(options.id);
  177. }
  178. },
  179. onShow() {
  180. this.getletterStauts();
  181. this.getInfos()
  182. tool.isLogin().then(res => {
  183. this.setData({
  184. userInfo: JSON.parse(res.rawData)
  185. })
  186. console.log(this.data.userInfo)
  187. }).catch(err => {
  188. console.log(err)
  189. })
  190. }
  191. })