index.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. //index.js
  2. //获取应用实例
  3. const app = getApp();
  4. const api = app.api;
  5. Page({
  6. data: {
  7. motto: 'Hello World',
  8. isShowPop: false,
  9. userInfo: {},
  10. hasUserInfo: false,
  11. settleInfo: undefined,
  12. bannerList: undefined,
  13. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  14. banner: ['https://resource.artouchstone.com/miniapp/artist/images/index/banner.png', 'https://resource.artouchstone.com/miniapp/artist/images/index/banner.png','https://resource.artouchstone.com/miniapp/artist/images/index/banner.png'],
  15. bannerIndex: 0,
  16. swiper:{
  17. indicatorDots: false,
  18. vertical: false,
  19. autoplay: true,
  20. interval: 5000,
  21. duration: 500
  22. }
  23. },
  24. //事件处理函数
  25. bindViewTap: function() {
  26. wx.navigateTo({
  27. url: '../logs/logs'
  28. })
  29. },
  30. /**
  31. * 生命周期函数--监听页面显示
  32. */
  33. onShow: function () {
  34. },
  35. getData(opt) {
  36. this.getUserSettleInfo();
  37. this.getBanner();
  38. if(opt){
  39. opt()
  40. }
  41. },
  42. getUserSettleInfo(opt){
  43. app.post(api.getUserSettleInfo,{},{
  44. needToken:false
  45. }).then(res => {
  46. console.log(res);
  47. this.setData({
  48. settleInfo: res.data
  49. })
  50. if(opt){
  51. opt()
  52. }
  53. })
  54. },
  55. getBanner(){
  56. app.post(api.getBanner,{code:'banner'},{ needToken:false}).then(res => {
  57. console.log(res);
  58. this.setData({
  59. bannerList: res.data
  60. })
  61. })
  62. },
  63. onShareAppMessage(){
  64. },
  65. currentHandle(e) {
  66. let {
  67. current
  68. } = e.detail
  69. this.setData({
  70. bannerIndex:current
  71. })
  72. },
  73. onLoad: function () {
  74. if (app.globalData.userInfo) {
  75. this.setData({
  76. userInfo: app.globalData.userInfo,
  77. hasUserInfo: true
  78. })
  79. } else if (this.data.canIUse){
  80. // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  81. // 所以此处加入 callback 以防止这种情况
  82. app.userInfoReadyCallback = res => {
  83. this.setData({
  84. userInfo: res.userInfo,
  85. hasUserInfo: true
  86. })
  87. }
  88. } else {
  89. // 在没有 open-type=getUserInfo 版本的兼容处理
  90. wx.getUserInfo({
  91. success: res => {
  92. app.globalData.userInfo = res.userInfo
  93. this.setData({
  94. userInfo: res.userInfo,
  95. hasUserInfo: true
  96. })
  97. }
  98. })
  99. }
  100. this.getData()
  101. },
  102. getUserInfo: function(e) {
  103. // console.log(e)
  104. app.globalData.userInfo = e.detail.userInfo
  105. this.setData({
  106. userInfo: e.detail.userInfo,
  107. hasUserInfo: true
  108. })
  109. },
  110. onSwiperTap: function(e){
  111. let index = e.target.dataset.index;
  112. wx.navigateTo({
  113. url: this.data.bannerList[index].redirectUrl
  114. })
  115. },
  116. enterMall: function () {
  117. const that = this;
  118. this.getUserSettleInfo(function(){
  119. const settleInfo = that.data.settleInfo;
  120. if(settleInfo.isVerification==0){
  121. that.showPop()
  122. }else if(settleInfo.artistCaStatus && settleInfo.artistCaStatus === 2){
  123. //艺术家认证通过
  124. wx.navigateTo({
  125. url: '/pages/user/artUpload/artUpload'
  126. })
  127. }else if(settleInfo.curatorCaStatus && settleInfo.curatorCaStatus === 1){
  128. //策展人认证中
  129. wx.navigateTo({
  130. url: '/pages/settled/success/success'
  131. })
  132. }else if(settleInfo.curatorCaStatus && settleInfo.curatorCaStatus === 2){
  133. //策展人认证通过
  134. wx.navigateTo({
  135. // url: '/pages/user/artUpload/artUpload'
  136. url: '/pages/settled/contacts/contacts'
  137. })
  138. }else if(settleInfo.companyCaStatus && settleInfo.companyCaStatus == 1){
  139. //公司入驻审核中
  140. wx.navigateTo({
  141. url: '/pages/settled/success/success'
  142. })
  143. }else if(settleInfo.companyCaStatus && settleInfo.companyCaStatus == 2){
  144. //公司入驻审核通过
  145. wx.navigateTo({
  146. url: '/pages/settled/contacts/contacts'
  147. })
  148. }else{
  149. wx.navigateTo({
  150. url: '/pages/settled/index/index'
  151. })
  152. }
  153. });
  154. },
  155. showPop(){
  156. this.setData({
  157. isShowPop:true
  158. });
  159. },
  160. hidePop(){
  161. this.setData({
  162. isShowPop:false
  163. });
  164. },
  165. /**
  166. * 邀请参展
  167. */
  168. invitation: function() {
  169. wx.navigateTo({
  170. url: '/pages/invitation/index/index',
  171. })
  172. }
  173. })