index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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.showLoading();
  61. wx.request({
  62. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/actives',
  63. method: "get",
  64. success: (res) => {
  65. if (res.data.code == 0) {
  66. this.setData({
  67. arr: res.data.actives
  68. })
  69. }
  70. },
  71. complete() {
  72. wx.hideLoading();
  73. }
  74. })
  75. },
  76. goInfo() {
  77. wx.redirectTo({
  78. url: '/pages/personInfo/personInfo',
  79. })
  80. },
  81. goMy() {
  82. wx.redirectTo({
  83. url: '/pages/personal/personal',
  84. })
  85. },
  86. getIntroduce(id) {
  87. wx.request({
  88. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/introduce',
  89. method: "get",
  90. data: {
  91. introduce: id
  92. },
  93. success: (res) => {
  94. console.log(res, '获取推荐人')
  95. }
  96. })
  97. },
  98. getletterStauts() {
  99. if (wx.getStorageSync('letterStatus') == true) {
  100. this.setData({
  101. letterStatus: true
  102. })
  103. } else {
  104. this.setData({
  105. letterStatus: false
  106. })
  107. }
  108. },
  109. // 获取个人信息用于客服所需参数
  110. getInfos() {
  111. wx.request({
  112. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/info',
  113. method: "get",
  114. success: (res) => {
  115. if (res.data.code == 0) {
  116. let config = 'ysf.config';
  117. let sex1 = '';
  118. if (res.data.info.sex == 0) {
  119. sex1 = '女'
  120. } else {
  121. sex1 = '男'
  122. }
  123. this.setData({
  124. myInfo: res.data.info,
  125. [config]: JSON.stringify({
  126. "uid": res.data.id, // 用户唯一标识
  127. "level": 1, // vip等级
  128. "data": JSON.stringify([{
  129. "index": 0,
  130. "key": "name",
  131. "label": "姓名",
  132. "value": res.data.info.name
  133. },
  134. {
  135. "index": 1,
  136. "key": "createTime",
  137. "label": "创建时间",
  138. "value": res.data.info.createTime
  139. },
  140. {
  141. "index": 2,
  142. "key": "sex",
  143. "label": "性别",
  144. "value": sex1
  145. },
  146. {
  147. "index": 3,
  148. "key": "tel",
  149. "label": "电话",
  150. "value": res.data.info.tel
  151. }
  152. ])
  153. })
  154. })
  155. }
  156. }
  157. })
  158. },
  159. onLoad(options) {
  160. tool.openidStatus().then(result => {
  161. this.setData({
  162. openid: result[0],
  163. sessionkey: result[1],
  164. })
  165. this.getActivies();
  166. this.getInfos()
  167. })
  168. if (options.id) {
  169. this.getIntroduce(options.id);
  170. }
  171. },
  172. onShow() {
  173. // 获取信件
  174. this.getletterStauts();
  175. this.getInfos()
  176. this.getActivies();
  177. wx.getSetting({
  178. success: res => {
  179. console.log(res)
  180. if (res.authSetting['scope.userInfo']) {
  181. wx.getUserInfo({
  182. success: res => {
  183. console.log(res)
  184. this.setData({
  185. userInfo:JSON.parse(res.rawData)
  186. })
  187. console.log(this.data.userInfo,'000000000000')
  188. }
  189. })
  190. }
  191. }
  192. })
  193. // tool.isLogin().then(res => {
  194. // this.setData({
  195. // userInfo:JSON.parse(res.rawData)
  196. // })
  197. // console.log(this.data.userInfo,'000000000000')
  198. // }).catch(err => {
  199. // console.log(err)
  200. // })
  201. }
  202. })