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

5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. userData: null,
  26. },
  27. /**
  28. * 关闭任务窗
  29. */
  30. hiddenTask:function(){
  31. this.setData({
  32. maskShow: false,
  33. taskShow: false
  34. })
  35. },
  36. /**
  37. * 签到
  38. */
  39. signIn() {
  40. app.wxRequest(app.globalData.urlRoot +"task/signToday",{},res=>{
  41. if (res.code == 200) {
  42. this.getTaskProgress();
  43. this.getShareId();
  44. this.setData({
  45. maskShow: false,
  46. isSign: false,
  47. isShare: false,
  48. showClose: true
  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. app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationInfo", {}, res => {
  84. if (res.code == 200) {
  85. if (!app.globalData.certificationInfo) {
  86. app.globalData.certificationInfo = true;
  87. wx.setStorageSync("certificationInfo", true);
  88. }
  89. app.globalData.certificationState = res.data.certificationState;
  90. wx.navigateTo({
  91. url: '/pages/scout/scout'
  92. })
  93. } else if (res.code == -307) {
  94. wx.navigateTo({
  95. url: '/pages/mobileVerification/mobileVerification'
  96. })
  97. } else if (res.code == -308) {
  98. wx.navigateTo({
  99. url: '/pages/scout/register/register'
  100. })
  101. }
  102. }, this);
  103. },
  104. /**
  105. * 生命周期函数--监听页面加载
  106. */
  107. onLoad: function (options) {
  108. app.globalData.nowPage = 2;
  109. if (app.globalData.userInfoData) {
  110. this.setData({
  111. userData: app.globalData.userInfoData
  112. })
  113. }
  114. if (options.shareId) {
  115. this.data.isFriendShare = options.shareId;
  116. }
  117. if (app.globalData.openid) {
  118. this.loadFun();
  119. } else {
  120. app.globalData.openidSuccessFuc = this.loadFun;
  121. }
  122. },
  123. loadFun: function () {
  124. this.getTaskProgress();
  125. this.getAddress();
  126. if (this.data.isFriendShare) {
  127. this.useShareId();
  128. }else{
  129. this.getSignInfo();
  130. }
  131. },
  132. /**
  133. * 生命周期函数--监听页面初次渲染完成
  134. */
  135. onReady: function () {
  136. },
  137. /**
  138. * 生命周期函数--监听页面显示
  139. */
  140. onShow: function () {
  141. },
  142. /**
  143. * 生命周期函数--监听页面隐藏
  144. */
  145. onHide: function () {
  146. },
  147. /**
  148. * 生命周期函数--监听页面卸载
  149. */
  150. onUnload: function () {
  151. },
  152. /**
  153. * 页面相关事件处理函数--监听用户下拉动作
  154. */
  155. onPullDownRefresh: function () {
  156. },
  157. /**
  158. * 页面上拉触底事件的处理函数
  159. */
  160. onReachBottom: function () {
  161. },
  162. /**
  163. * 用户点击右上角分享
  164. */
  165. onShareAppMessage: function (e) {
  166. if (e.from == "button") {
  167. return {
  168. title: '我正在参与“星探计划”,快来帮我解锁拼图吧,共享大奖!',
  169. imageUrl: this.data.imgUrl + "/shareImgs/" + Math.floor(Math.random() * 8 + 1) + ".jpg",
  170. path: this.data.shareId ? "/pages/everyday/everyday?shareId=" + this.data.shareId : "/pages/everyday/everyday"
  171. }
  172. }else{
  173. return app.sharePack();
  174. }
  175. },
  176. getTaskProgress: function () {//获取任务完成度
  177. app.wxRequest(app.globalData.urlRoot + "task/getTaskProgress", { taskType: 1 }, res => {
  178. if (res.code == 200) {
  179. this.setData({
  180. picturlList: res.data
  181. })
  182. } else {
  183. wx.showToast({
  184. title: res.msg,
  185. icon: "none"
  186. })
  187. }
  188. }, this);
  189. },
  190. receive:function(){//领取购车红包
  191. this.getTaskAward();
  192. },
  193. getAddress: function () {//获取地址
  194. app.wxRequest(app.globalData.urlRoot + "address/getAddress", {}, res => {
  195. if (res.code == 200) {
  196. if(res.data){
  197. this.data.isAddress = true;
  198. }
  199. } else {
  200. wx.showToast({
  201. title: res.msg,
  202. icon: "none"
  203. })
  204. }
  205. }, this);
  206. },
  207. getTaskAward:function(){//领取购车券
  208. app.wxRequest(app.globalData.urlRoot + "award/getTaskAward", { awardGiveId: this.data.picturlList[this.data.picturlCurrent]['awardGiveId']},res=>{
  209. if(res.code==200){
  210. this.data.picturlList[this.data.picturlCurrent]['awardState'] = -1;
  211. this.setData({
  212. getReward:res.data,
  213. picturlList: this.data.picturlList
  214. })
  215. if (res.data.needAddress != 0 && !this.data.isAddress){
  216. this.setData({
  217. tipWindow: 2
  218. })
  219. } else if (res.data.needAddress == 0){
  220. this.setData({
  221. tipWindow: 1
  222. })
  223. }
  224. }else{
  225. wx.showToast({
  226. title: res.msg,
  227. icon:"none"
  228. })
  229. }
  230. },this);
  231. },
  232. userRegister: function () {
  233. wx.navigateTo({
  234. url: '/pages/address/address',
  235. })
  236. },
  237. getSignInfo: function () {//查看当日是否签到
  238. app.wxRequest(app.globalData.urlRoot + "task/getSignInfo", {}, res => {
  239. if(res.code==200){
  240. if (res.data.state==0) {//未签到
  241. this.setData({
  242. showClose: false,
  243. maskShow: true,
  244. taskShow: true,
  245. isSign: true
  246. })
  247. }else{
  248. this.getShareId();
  249. }
  250. }
  251. },this)
  252. },
  253. getShareId: function () {//获取分享id(查询今日是否已被助力)
  254. app.wxRequest(app.globalData.urlRoot + "task/getShareId", {}, res => {
  255. if (res.code == 200) {
  256. if (res.data.shareId){
  257. this.setData({
  258. showClose: true,
  259. maskShow: true,
  260. taskShow: true,
  261. isShare: true
  262. })
  263. }
  264. var taskName = "集齐启辰星【" + res.data.shortName + "】碎片" + res.data.completeNum + "/" + res.data.childTotal;
  265. this.setData({
  266. taskName: taskName,
  267. taskImgUrl: res.data.popPicUrl,
  268. })
  269. this.data.shareId = res.data.shareId;
  270. }
  271. }, this)
  272. },
  273. useShareId: function (shareId) {//发起助力
  274. app.wxRequest(app.globalData.urlRoot + "task/useShareId", { shareId: this.data.isFriendShare}, res => {
  275. if(res.code==200){
  276. this.setData({
  277. hiddenFriendFrame: true,
  278. useShareData: res.data,
  279. maskShow: false
  280. })
  281. } else {
  282. this.getSignInfo();
  283. // wx.showToast({
  284. // title: res.msg,
  285. // icon:"none"
  286. // })
  287. }
  288. }, this,"POST")
  289. },
  290. swiperChange(e) {//通过鼠标滑动改变swiper时
  291. if (e.detail.source == "touch") {
  292. this.setData({
  293. picturlCurrent: e.detail.current,
  294. })
  295. }
  296. },
  297. ruleControl:function(e){
  298. this.setData({
  299. showRule: e.currentTarget.dataset.state
  300. })
  301. },
  302. hiddenFriendTip: function () {
  303. this.getSignInfo();
  304. this.setData({
  305. hiddenFriendFrame:false
  306. })
  307. },
  308. getUserWxMsg: function (e) {
  309. if (e.detail.errMsg == "getUserInfo:ok") {
  310. this.setData({
  311. userData: e.detail.userInfo
  312. })
  313. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  314. }
  315. },
  316. closeWindow:function(){//
  317. this.setData({
  318. tipWindow:0
  319. })
  320. }
  321. })