东风启辰小程序端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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