index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. this.setData({
  29. letterStatus: true
  30. })
  31. wx.setStorageSync('letterStatus', true)
  32. },
  33. goShare() {
  34. wx.navigateTo({
  35. url: '/pages/share/share',
  36. })
  37. },
  38. // 跳转活动详情页面
  39. goActive(e) {
  40. if (e.currentTarget.dataset.activestatus != -1) {
  41. let id = e.currentTarget.dataset.id
  42. let openId = e.currentTarget.dataset.openid
  43. wx.navigateTo({
  44. url: '/pages/activeDetail/activeDetail?id=' + id + '&openId=' + openId,
  45. })
  46. } else {
  47. wx.showModal({
  48. title: '活动已经结束啦',
  49. showCancel: false
  50. });
  51. }
  52. },
  53. goActiveDefault() {
  54. wx.navigateTo({
  55. url: '/pages/activeDefaultDetails/activeDefaultDetails',
  56. })
  57. },
  58. // 获取活动列表
  59. getActivies() {
  60. wx.request({
  61. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/actives',
  62. method: "get",
  63. success: (res) => {
  64. if (res.data.code == 0) {
  65. this.setData({
  66. arr: res.data.actives
  67. })
  68. }
  69. },
  70. complete() {
  71. wx.hideLoading();
  72. }
  73. })
  74. },
  75. goInfo() {
  76. wx.redirectTo({
  77. url: '/pages/personInfo/personInfo',
  78. })
  79. },
  80. goMy() {
  81. wx.redirectTo({
  82. url: '/pages/personal/personal',
  83. })
  84. },
  85. getIntroduce(id) {
  86. wx.request({
  87. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/introduce',
  88. method: "get",
  89. data: {
  90. introduce: id
  91. },
  92. success: (res) => {
  93. console.log(res, '获取推荐人')
  94. }
  95. })
  96. },
  97. getletterStauts() {
  98. if (wx.getStorageSync('letterStatus') == true) {
  99. this.setData({
  100. letterStatus: true
  101. })
  102. } else {
  103. this.setData({
  104. letterStatus: false
  105. })
  106. }
  107. },
  108. getInfos() {
  109. wx.request({
  110. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/info',
  111. method: "get",
  112. success: (res) => {
  113. if (res.data.code == 0) {
  114. let config='ysf.config';
  115. let sex1 = '';
  116. if(res.data.info.sex==0){
  117. sex1='女'
  118. }else{
  119. sex1='男'
  120. }
  121. this.setData({
  122. myInfo: res.data.info,
  123. [config]:JSON.stringify({
  124. "uid": res.data.id, // 用户唯一标识
  125. "level": 1, // vip等级
  126. "data": JSON.stringify([{
  127. "index": 0,
  128. "key": "name",
  129. "label": "姓名",
  130. "value": res.data.info.name
  131. },
  132. {
  133. "index": 1,
  134. "key": "createTime",
  135. "label": "创建时间",
  136. "value": res.data.info.createTime
  137. },
  138. {
  139. "index": 2,
  140. "key": "sex",
  141. "label": "性别",
  142. "value": sex1
  143. },
  144. {
  145. "index": 3,
  146. "key": "tel",
  147. "label": "电话",
  148. "value": res.data.info.tel
  149. }
  150. ])
  151. })
  152. })
  153. }
  154. }
  155. })
  156. },
  157. onLoad(options) {
  158. tool.openidStatus().then(result => {
  159. this.setData({
  160. openid: result[0],
  161. sessionkey: result[1],
  162. })
  163. this.getActivies();
  164. this.getInfos()
  165. })
  166. if (options.id) {
  167. this.getIntroduce(options.id);
  168. }
  169. },
  170. onShow() {
  171. this.getletterStauts();
  172. this.getInfos()
  173. tool.isLogin().then(res => {
  174. this.setData({
  175. userInfo:JSON.parse(res.rawData)
  176. })
  177. }).catch(err => {
  178. console.log(err)
  179. })
  180. }
  181. })