东风启辰小程序端
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

249 líneas
5.6KB

  1. // pages/everyday/everyday.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: app.globalData.urlStatic,//图片路径
  9. showClose:false,
  10. maskShow: false,
  11. taskShow: false,
  12. taskName:'集齐启辰星【大灯】碎片',
  13. taskImgUrl:'https://www.jiyou-tech.com/2020/496_qichen/static/star/everyday/taskImg1.png',
  14. isSign:true,
  15. isShare:false,
  16. picturlList: [],
  17. picturlCurrent:0,
  18. isRegister:false,//是否已注册
  19. shareId:null,
  20. isFriendShare:false,//是否朋友分享过来的
  21. },
  22. /**
  23. * 关闭任务窗
  24. */
  25. hiddenTask:function(){
  26. this.setData({
  27. maskShow: false,
  28. taskShow: false
  29. })
  30. },
  31. /**
  32. * 签到
  33. */
  34. signIn() {
  35. app.wxRequest(app.globalData.urlRoot +"task/signToday",{},res=>{
  36. if (res.code == 200) {
  37. if (!this.data.shareId) {
  38. this.setData({
  39. maskShow: false
  40. })
  41. } else {
  42. this.setData({
  43. taskName: '集齐启辰星【大灯】碎片1/4',
  44. taskImgUrl: 'https://www.jiyou-tech.com/2020/496_qichen/static/star/everyday/taskImg2.png',
  45. isSign: false,
  46. isShare: true,
  47. showClose: true
  48. })
  49. }
  50. }else{
  51. wx.showToast({
  52. title: res.msg,
  53. icon:"none"
  54. })
  55. }
  56. },this,"POST");
  57. },
  58. /**
  59. * 下个碎片
  60. */
  61. nextPicturl(){
  62. var max = this.data.picturlList.length-1;
  63. var current = this.data.picturlCurrent + 1;
  64. if (current <= max){
  65. this.setData({
  66. picturlCurrent: current
  67. })
  68. }
  69. },
  70. //上一个碎片
  71. prevPicturl(){
  72. var current = this.data.picturlCurrent - 1;
  73. if (current >= 0) {
  74. this.setData({
  75. picturlCurrent: current
  76. })
  77. }
  78. },
  79. /**
  80. * 星探任务
  81. */
  82. goScout(){
  83. wx.navigateTo({
  84. url: '../scout/scout'
  85. })
  86. },
  87. /**
  88. * 生命周期函数--监听页面加载
  89. */
  90. onLoad: function (options) {
  91. app.globalData.nowPage = 2;
  92. if (options.shareId) {
  93. this.data.isFriendShare = options.shareId;
  94. }
  95. if (app.globalData.openid) {
  96. this.loadFun();
  97. } else {
  98. app.globalData.openidSuccessFuc = this.loadFun;
  99. }
  100. },
  101. loadFun: function () {
  102. this.getTaskProgress();
  103. this.getOrderInfo();
  104. // this.getShareId();
  105. if (this.data.isFriendShare) {
  106. this.useShareId();
  107. }
  108. },
  109. /**
  110. * 生命周期函数--监听页面初次渲染完成
  111. */
  112. onReady: function () {
  113. },
  114. /**
  115. * 生命周期函数--监听页面显示
  116. */
  117. onShow: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面隐藏
  121. */
  122. onHide: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面卸载
  126. */
  127. onUnload: function () {
  128. },
  129. /**
  130. * 页面相关事件处理函数--监听用户下拉动作
  131. */
  132. onPullDownRefresh: function () {
  133. },
  134. /**
  135. * 页面上拉触底事件的处理函数
  136. */
  137. onReachBottom: function () {
  138. },
  139. /**
  140. * 用户点击右上角分享
  141. */
  142. onShareAppMessage: function () {
  143. return {
  144. title: '我正在参与“星探计划”,快来帮我解锁拼图吧,共享大奖!',
  145. imageUrl: this.data.imgUrl + "/shareImgs/" + Math.floor(Math.random() * 8 + 1)+".jpg",
  146. path: this.data.shareId ? "/pages/everyday/everyday?shareId=" + this.data.shareId :"/pages/everyday/everyday"
  147. }
  148. },
  149. getTaskProgress: function () {//获取任务完成度
  150. app.wxRequest(app.globalData.urlRoot + "task/getTaskProgress", { taskType: 1 }, res => {
  151. if (res.code == 200) {
  152. this.setData({
  153. picturlList: res.data
  154. })
  155. } else {
  156. wx.showToast({
  157. title: res.msg,
  158. icon: "none"
  159. })
  160. }
  161. }, this);
  162. },
  163. getOrderInfo: function () {//查询是否已注册
  164. app.wxRequest(app.globalData.urlRoot + "userInfo/getOrderInfo", {}, res => {
  165. if (res.code == 200) {
  166. if (res.data) {
  167. this.setData({
  168. isRegister: true
  169. })
  170. // app.globalData.isRegister = true;
  171. app.globalData.userMobile = res.data.mobile;
  172. }
  173. } else {
  174. console.log(res.msg)
  175. }
  176. }, this);
  177. },
  178. receive:function(){//领取购车红包
  179. if (this.data.isRegister){
  180. wx.redirectTo({
  181. url: '../myCenter/myCenter'
  182. })
  183. }else{
  184. wx.navigateTo({
  185. url: '../receiveRegister/receiveRegister',
  186. })
  187. }
  188. },
  189. getSignInfo: function () {//查看当日是否签到
  190. app.wxRequest(app.globalData.urlRoot + "task/getSignInfo", {}, res => {
  191. if(res.code==200){
  192. if (res.data.state==0) {//未签到
  193. this.setData({
  194. showClose: false,
  195. maskShow: true,
  196. taskShow: true,
  197. isSign: true
  198. })
  199. }else{
  200. if (this.data.shareId){
  201. this.setData({
  202. showClose: true,
  203. maskShow: true,
  204. taskShow: true,
  205. isShare: true
  206. })
  207. }
  208. }
  209. }
  210. },this)
  211. },
  212. getShareId: function () {//获取分享id(查询今日是否已被助力)
  213. app.wxRequest(app.globalData.urlRoot + "task/getShareId", {}, res => {
  214. this.getSignInfo();
  215. if (res.code == 200) {
  216. this.data.shareId = res.data.shareId;
  217. }
  218. }, this)
  219. },
  220. useShareId: function (shareId) {//发起助力
  221. app.wxRequest(app.globalData.urlRoot + "task/useShareId", { shareId: this.data.isFriendShare}, res => {
  222. console.log(res);
  223. this.setData({
  224. maskShow:false
  225. })
  226. }, this,"POST")
  227. },
  228. swiperChange(e) {//通过鼠标滑动改变swiper时
  229. if (e.detail.source == "touch") {
  230. this.setData({
  231. picturlCurrent: e.detail.current,
  232. })
  233. }
  234. }
  235. })