东风启辰小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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