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