东风启辰小程序端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

240 rindas
5.3KB

  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. picturlName:[],
  17. picturlList: ['picturePuzzle1', 'picturePuzzle1'],
  18. picturlCurrent:0,
  19. isRegister:false,//是否已注册
  20. shareId:null,
  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 (app.globalData.openid) {
  93. this.loadFun();
  94. } else {
  95. app.globalData.openidSuccessFuc = this.loadFun;
  96. }
  97. },
  98. loadFun: function () {
  99. this.getTaskProgress();
  100. this.getOrderInfo();
  101. this.getShareId();
  102. },
  103. /**
  104. * 生命周期函数--监听页面初次渲染完成
  105. */
  106. onReady: function () {
  107. },
  108. /**
  109. * 生命周期函数--监听页面显示
  110. */
  111. onShow: function () {
  112. },
  113. /**
  114. * 生命周期函数--监听页面隐藏
  115. */
  116. onHide: function () {
  117. },
  118. /**
  119. * 生命周期函数--监听页面卸载
  120. */
  121. onUnload: function () {
  122. },
  123. /**
  124. * 页面相关事件处理函数--监听用户下拉动作
  125. */
  126. onPullDownRefresh: function () {
  127. },
  128. /**
  129. * 页面上拉触底事件的处理函数
  130. */
  131. onReachBottom: function () {
  132. },
  133. /**
  134. * 用户点击右上角分享
  135. */
  136. onShareAppMessage: function () {
  137. this.useShareId();
  138. return {
  139. title: '我正在参与“星探计划”,快来帮我 解锁内饰碎片吧,共享大奖!',
  140. imageUrl: "",
  141. path: "/pages/everyday/everyday"
  142. }
  143. },
  144. getTaskProgress: function () {//获取任务完成度
  145. app.wxRequest(app.globalData.urlRoot + "task/getTaskProgress", { taskType: 1 }, res => {
  146. if (res.code == 200) {
  147. for(let i=0;i<res.data.length;i++){
  148. this.data.picturlName.push(res.data[i].taskName);
  149. }
  150. this.setData({
  151. picturlName: this.data.picturlName
  152. })
  153. } else {
  154. wx.showToast({
  155. title: res.msg,
  156. icon: "none"
  157. })
  158. }
  159. }, this);
  160. },
  161. getOrderInfo: function () {//查询是否已注册
  162. app.wxRequest(app.globalData.urlRoot + "userInfo/getOrderInfo", {}, res => {
  163. if (res.code == 200) {
  164. if (res.data) {
  165. this.setData({
  166. isRegister: true
  167. })
  168. // app.globalData.isRegister = true;
  169. app.globalData.userMobile = res.data.mobile;
  170. }
  171. } else {
  172. console.log(res.msg)
  173. }
  174. }, this);
  175. },
  176. receive:function(){//领取购车红包
  177. if (this.data.isRegister){
  178. wx.redirectTo({
  179. url: '../myCenter/myCenter'
  180. })
  181. }else{
  182. wx.navigateTo({
  183. url: '../receiveRegister/receiveRegister',
  184. })
  185. }
  186. },
  187. getSignInfo: function () {//查看当日是否签到
  188. app.wxRequest(app.globalData.urlRoot + "task/getSignInfo", {}, res => {
  189. if(res.code==200){
  190. if (res.data.state==0) {//未签到
  191. this.setData({
  192. showClose: false,
  193. maskShow: true,
  194. taskShow: true,
  195. isSign: true
  196. })
  197. }else{
  198. if (this.data.shareId){
  199. this.setData({
  200. showClose: true,
  201. maskShow: true,
  202. taskShow: true,
  203. isShare: true
  204. })
  205. }
  206. }
  207. }
  208. },this)
  209. },
  210. getShareId: function () {//获取分享id(查询今日是否已被助力)
  211. app.wxRequest(app.globalData.urlRoot + "task/getShareId", {}, res => {
  212. this.getSignInfo();
  213. if (res.code == 200) {
  214. this.data.shareId = res.data.shareId;
  215. }
  216. }, this)
  217. },
  218. useShareId: function () {//发起助力
  219. app.wxRequest(app.globalData.urlRoot + "task/useShareId", { shareId:this.data.shareId}, res => {
  220. console.log(res);
  221. this.setData({
  222. maskShow:false
  223. })
  224. }, this,"POST")
  225. }
  226. })