From 2b75eba33d48671a2a90b47383bf28289d51546b Mon Sep 17 00:00:00 2001 From: meo <18801474720@163.com> Date: Thu, 13 Jun 2019 23:42:57 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=88=91=E7=9A=84=E6=B4=BB=E5=8A=A8][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9]:[=E5=A2=9E=E5=8A=A0=E6=88=91=E7=9A=84?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=88=97=E8=A1=A8=E4=BB=A5=E5=8F=8A=E8=AF=A6?= =?UTF-8?q?=E6=83=85]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 1 + config/config.js | 5 +- pages/radetail/index.js | 10 +- pages/radetail/index.wxss | 10 + pages/radetail/joinActivity/edit.js | 161 ++++++++++----- pages/radetail/joinActivity/edit.wxml | 6 + pages/radetail/joinActivity/edit.wxss | 29 +++ pages/user/index.wxml | 9 +- pages/user/myactivity/index.js | 168 +++++++++++++++ pages/user/myactivity/index.json | 7 + pages/user/myactivity/index.wxml | 29 +++ pages/user/myactivity/index.wxss | 283 ++++++++++++++++++++++++++ 12 files changed, 658 insertions(+), 60 deletions(-) create mode 100644 pages/user/myactivity/index.js create mode 100644 pages/user/myactivity/index.json create mode 100644 pages/user/myactivity/index.wxml create mode 100644 pages/user/myactivity/index.wxss diff --git a/app.json b/app.json index a3688e2..2358f2c 100644 --- a/app.json +++ b/app.json @@ -29,6 +29,7 @@ "pages/phoneinput/phoneinput", "pages/market/index", "pages/user/index", + "pages/user/myactivity/index", "pages/coupon/detail/index", "pages/rushToBuy/index", "pages/couponorder/index/index", diff --git a/config/config.js b/config/config.js index 819faa1..924c5e3 100755 --- a/config/config.js +++ b/config/config.js @@ -301,7 +301,10 @@ var config = { acfindById:"/wxActivity/findById", acPrintHtmlById:"/wxActivity/printHtmlById", //参与活动 - activityJoin:"/wxActivityJoin/join" + activityJoin:"/wxActivityJoin/join", + //签到 + activitySign:"/wxActivityJoin/sign", + activityList: "/wxActivityJoin/list" }, weapp: { AppId: weappId diff --git a/pages/radetail/index.js b/pages/radetail/index.js index 0ea383b..b79bb35 100644 --- a/pages/radetail/index.js +++ b/pages/radetail/index.js @@ -4,12 +4,15 @@ const Http = require("../../utils/HttpBasics"); const util = require("../../utils/util"); var WxParse = require('../../wxParse/wxParse.js'); const imgurl = require("../../utils/imgurl"); +const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {} +let configUrls = extConfig.attr.configUrl; Page({ data: { data: {}, status:1, couponId: null, orderId: "", + question:[], day: "", hour: "", activityId:"", @@ -33,9 +36,14 @@ Page({ that.setData({ data: res.data.activity }) + if (res.data && res.data.activity && res.data.activity.question){ + that.setData({ + question: JSON.parse(res.data.activity.question) + }) + } if (res.data.activity.type == 2) { wx.request({ - url: 'https://ciformall.youlane.cn/C/api' + config.api.acPrintHtmlById, + url: configUrls + config.api.acPrintHtmlById, data: { id: options.id, date: new Date(), diff --git a/pages/radetail/index.wxss b/pages/radetail/index.wxss index 2e96763..4b408b9 100644 --- a/pages/radetail/index.wxss +++ b/pages/radetail/index.wxss @@ -1140,4 +1140,14 @@ button::after{ border: none; } .time{ font-size: 30rpx; line-height: 50rpx; +} +.ques{ + display: block; + text-align: center; +} +.questionTitle{ + width: 180rpx; + font-size: 40rpx; + border-top:6rpx solid orange; + margin: 20rpx auto 0; } \ No newline at end of file diff --git a/pages/radetail/joinActivity/edit.js b/pages/radetail/joinActivity/edit.js index 656541e..9d41940 100644 --- a/pages/radetail/joinActivity/edit.js +++ b/pages/radetail/joinActivity/edit.js @@ -8,22 +8,30 @@ Page({ data: { date: '1988-03-12', flag: 1, + answerflag: "", flagsex: 0, - items: [ - { name: 1, value: '男', checked: false }, - { name: 2, value: '女', checked: false }, + items: [{ + name: 1, + value: '男', + checked: false + }, + { + name: 2, + value: '女', + checked: false + }, ], username: "", array: ['上班族', '学生', '企业高管', '个体户', '自由职业', '其他'], array1: ['附近住户', '距离2km', '距离3km', '更远'], index: 0, index1: 0, - showPage:false + showPage: false }, /** * 获得生日 */ - bindDateChange: function (e) { + bindDateChange: function(e) { this.setData({ date: e.detail.value, flag: 2 @@ -32,7 +40,7 @@ Page({ /** * 职业 */ - bindPickerChange: function (e) { + bindPickerChange: function(e) { this.setData({ index: e.detail.value }) @@ -40,29 +48,32 @@ Page({ /** * 生活半径 */ - bindPickerChange1: function (e) { + bindPickerChange1: function(e) { this.setData({ index1: e.detail.value }) }, - address: function () { + address: function() { let that = this; wx.chooseLocation({ - success: function (res) { + success: function(res) { that.setData({ address: res.name + '(' + res.address + ')', addressStr: JSON.stringify(res) }) }, - fail: function (error) { + fail: function(error) { console.log(error) }, - complete: function (data) { - } + complete: function(data) {} }) }, - formSubmit: function (e) { + change(value){ + console.log(value) + }, + formSubmit: function(e) { let that = this; + console.log(e) /** * sex * 0 保密 @@ -76,17 +87,14 @@ Page({ } if (that.data.addressStr) { var address = that.data.addressStr; - } - else { + } else { var address = null; } if (e.detail.value.username) { var username = e.detail.value.username; - } - else if (that.data.username) { + } else if (that.data.username) { var username = that.data.username; - } - else { + } else { var username = null; } if (that.data.flag == 2 && that.data.date) { @@ -94,44 +102,72 @@ Page({ } else { var birthday = null; } + + //获得答案 + delete e.detail.value.username; + let obj = e.detail.value; + if (that.data&&that.data.question&&that.data.question.length>0){ + let valArr22; + valArr22 = Object.keys(obj).map(function (item,index) { + if (!obj[item]){ + wx.showToast({ + title: '问卷调查回答不完整,请补充', + duration:2000, + icon:"none" + }) + that.setData({ + answerflag:"noanswer" + }) + }else{ + that.setData({ + answerflag: "answer" + }) + return { ques: that.data.question[index].ques, answer: obj[item] } + } + }); + this.setData({ + answer:valArr22 + }); + } + if (username == null || address == null || sex == 0 || birthday == null) { wx.showToast({ title: '请输入完整的用户信息', - icon:"none" + icon: "none" }) } else { - Http.post({ - url: config.api.activityJoin, - data: { - sex: sex, - address: address, - name: username, - birthday: birthday, - activityId: that.data.activityId - } - }) - .then(res => { - wx.showToast({ - title: "提交成功", - icon: 'none', - duration: 2000, - mask: false + console.log(that.data.answer) + if (this.data.answerflag == 'noanswer'){ + + }else{ + Http.post({ + url: config.api.activityJoin, + data: { + sex: sex, + address: address, + name: username, + birthday: birthday, + answer: JSON.stringify(that.data.answer), + activityId: that.data.activityId + } }) - wx.navigateTo({ - url: '/pages/radetail/success/index', + .then(res => { + wx.redirectTo({ + url: '/pages/radetail/success/index', + }) + }) + .catch(err => { + wx.showToast({ + title: err.message, + icon: 'none', + duration: 2000, + mask: false + }) }) - }) - .catch(err => { - wx.showToast({ - title: err.message, - icon: 'none', - duration: 2000, - mask: false - }) - }) + } } }, - radioChange: function (e) { + radioChange: function(e) { this.setData({ sex: e.detail.value, flagsex: 1 @@ -140,12 +176,37 @@ Page({ /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { + onLoad: function(options) { let that = this; - if (options && options.activityId){ + if (options && options.activityId) { that.setData({ activityId: options.activityId }) + that.getDetail(options.activityId); } + }, + getDetail(activityId) { + let that = this; + Http.get({ + url: config.api.acfindById, + data: { + id: activityId + } + }).then(res => { + if (res && res.data && res.data.activity) { + if (res.data && res.data.activity && res.data.activity.question) { + that.setData({ + question: JSON.parse(res.data.activity.question) + }) + } + } + }).catch(err => { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }) + }) } }) \ No newline at end of file diff --git a/pages/radetail/joinActivity/edit.wxml b/pages/radetail/joinActivity/edit.wxml index 461e55d..40e08b8 100644 --- a/pages/radetail/joinActivity/edit.wxml +++ b/pages/radetail/joinActivity/edit.wxml @@ -24,5 +24,11 @@ {{address}} 请选择地址 + + 调查问卷 + {{index+1}}.{{item.ques}} + + + \ No newline at end of file diff --git a/pages/radetail/joinActivity/edit.wxss b/pages/radetail/joinActivity/edit.wxss index d18b170..383eb3b 100644 --- a/pages/radetail/joinActivity/edit.wxss +++ b/pages/radetail/joinActivity/edit.wxss @@ -64,6 +64,7 @@ radio { border-radius:60rpx; background: orange; font-size: 32rpx; + z-index: 1000; } .active{ opacity: .6; @@ -84,4 +85,32 @@ radio { font-size: 26rpx; line-height: 46rpx; color: #999; +} +.ques{ + padding-left: 20rpx; + margin-bottom:140rpx; +} +.ques text{ + display: block; + text-align: center; +} +.questionTitle{ + width: 180rpx; + font-size: 40rpx; + border-top:6rpx solid orange; + border-bottom:6rpx solid orange; + margin: 40rpx auto 0; +} +.ques text{ + display: block; +} +.answer{ + margin-bottom: 20rpx; +} +.answer textarea{ + border: 1rpx solid #efefef; + border-radius: 10rpx; + padding: 10rpx 0; + margin-top: 10rpx; + padding-left: 10rpx; } \ No newline at end of file diff --git a/pages/user/index.wxml b/pages/user/index.wxml index 1bcae5f..0ed9bd2 100644 --- a/pages/user/index.wxml +++ b/pages/user/index.wxml @@ -78,19 +78,12 @@ 我的拼团 - + 我的活动 - - - - 我的奖品 - - - diff --git a/pages/user/myactivity/index.js b/pages/user/myactivity/index.js new file mode 100644 index 0000000..e55ed37 --- /dev/null +++ b/pages/user/myactivity/index.js @@ -0,0 +1,168 @@ +let config = require("../../../config/config.js"); +let Http = require("../../../utils/HttpBasics"); +const util = require("../../../utils/util"); +let app = getApp(); +const imgurl = require("../../../utils/imgurl"); +Page({ + data: { + dingdanUrl: imgurl.dingdan.url, + loadingUrl: imgurl.loading.url, + wmhome: imgurl.wmhome.url, + wmdiscount: imgurl.wmdiscount.url, + wmgive: imgurl.wmgive.url, + tabs: [ + { + key: 0, + name: "参与中" + }, + { + key: 1, + name: "已过期" + } + ], + list: [], + current: "", + loading: true, //"上拉加载"的变量,默认false,隐藏 + current_scroll: "0", + allow_load: true, + page: 1, + content: "", + }, + goback: function () { + wx.switchTab({ + url: '/pages/main/index', + }) + }, + onLoad(options) { + this.getList(0, 1); + this.setData({ + current_scroll: 0 + }); + }, + //活动详情 + gotoDetail:function(e){ + wx.navigateTo({ + url: `/pages/radetail/index?id=${e.currentTarget.dataset.id}` + }) + }, + gotopay: function (e) { + wx.navigateTo({ + url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}&flag='pay'` + }) + }, + getList(key, pageNum) { + let that = this; + let variable; + if(key == 0){ + variable = { + pageNum: pageNum, + pageSize: 15, + statusStr:"0,1,2" + }; + }else if(key == 1){ + variable = { + pageNum: pageNum, + pageSize: 15, + status: 3 + }; + } + + if (that.data.allow_load) { + that.setData({ + loading: true, + content: '小主,我在玩命加载中...' + }) + + Http.get({ + url: config.api.activityList, + data: variable + }).then(res => { + if (pageNum >= res.data.pages) { + that.setData({ + allow_load: false + }); + setTimeout(function () { + that.setData({ + loading: false, + }) + }, 1400); + } + setTimeout(function () { + that.setData({ + loading: false, + }) + }, 1400); + if (pageNum == 1) { + that.setData({ + list: [] + }) + } + var tmpArr = that.data.list; + tmpArr.push.apply(tmpArr, res.data.list); + // 将砍价的状态过滤出来 + console.log(tmpArr) + that.setData({ + list: tmpArr + }) + for (let i = 0; i < that.data.list.length; i++) { + var activityStartTime1 = util.formatTime(that.data.list[i].activityStartTime, "yyyy-MM-dd hh:mm:ss"); + var activityEndTime1 = util.formatTime(that.data.list[i].activityEndTime, "yyyy-MM-dd hh:mm:ss"); + /** + * 修改list的endtime + * 渲染到页面 + */ + var activityStartTime = 'list[' + i + '].activityStartTime' + var activityEndTime = 'list[' + i + '].activityEndTime' + that.setData({ + [activityStartTime]: activityStartTime1, + [activityEndTime]: activityEndTime1, + }); + } + }) + .catch(err => { + wx.showToast({ + title: err.errMsg, + icon:"none", + duration:2000 + }) + }) + } + else { + that.setData({ + loading: true, + content: "——— 再拉裤子就掉了啦 ———" + }) + setTimeout(function () { + that.setData({ + loading: false, + }) + }, 1400) + } + }, + handleChange({ + detail + }) { + this.setData({ + current: detail.key + }); + }, + handleChangeScroll({ + detail + }) { + this.setData({ + list: [], + allow_load: true, + current_scroll: detail.key, + page: 1 + }) + this.getList(detail.key, 1); + }, + onReachBottom: function () { + var that = this; + that.data.page++; + that.setData({ + page: that.data.page + }); + that.getList(that.data.current_scroll, that.data.page); + }, +}); \ No newline at end of file diff --git a/pages/user/myactivity/index.json b/pages/user/myactivity/index.json new file mode 100644 index 0000000..25e291a --- /dev/null +++ b/pages/user/myactivity/index.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "i-tab": "../../../dist/tab/index", + "i-tabs": "../../../dist/tabs/index" + }, + "navigationBarTitleText": "我的活动" +} \ No newline at end of file diff --git a/pages/user/myactivity/index.wxml b/pages/user/myactivity/index.wxml new file mode 100644 index 0000000..b2dd4d9 --- /dev/null +++ b/pages/user/myactivity/index.wxml @@ -0,0 +1,29 @@ + + + + + + + + + + {{item.title}} + + 活动开始日期:{{item.activityStartTime}} + 活动结束日期:{{item.activityEndTime}} + + + + + + + 您还没有参加活动 + + + + + {{content}} + + \ No newline at end of file diff --git a/pages/user/myactivity/index.wxss b/pages/user/myactivity/index.wxss new file mode 100644 index 0000000..e472aa0 --- /dev/null +++ b/pages/user/myactivity/index.wxss @@ -0,0 +1,283 @@ +.market { + width: 100%; + height: 100%; +} + +.tabs { + position: fixed; + width: 100% !important; + height: 88rpx; + top: 0; + left: 0; + right: 0; + text-align: center; + z-index: 10000000; +} + +.i-tab { + width: 30% !important; + display: inline-block; +} + +.detail_msg { + position: relative; + background: #fff; + margin: 0 30rpx; + border-radius: 16rpx; + overflow: hidden; +} +.sendImg{ + position: absolute; + width: 100rpx; + top: 100rpx; + right: 6rpx; +} + +.logo { + display: block; + width: 100%; + border-radius: 16rpx; +} + +.logo image { + display: block; + width: 100%; + height: 260rpx; + border-radius: 16rpx; +} +.section{ + margin-bottom: 25rpx; +} +.info view:nth-child(1) { + font-size: 32rpx; + margin-top: 40rpx; + margin-bottom: 23rpx; + justify-content: space-between; + padding: 0 0 0 4%; +} +.info text,view{ + font-size: 26rpx; + text-align: center; + display: block; + color: #efefef; +} +.info { + width: 100%; + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + margin: auto; + text-align: center; + color: #fff; + background: rgba(0, 0, 0, 0.5) +} + +.sub { + font-size: 24rpx !important; + color: #919191 !important; + letter-spacing: 0; + line-height: 33rpx; + padding-left: 4%; + height: 66rpx; + overflow: hidden; + white-space: wrap; +text-overflow: ellipsis; +} + +.info view:nth-child(1) text { + display: inline-block; + width: 300rpx; + font-size: 30rpx; + letter-spacing: 0; + height: 42rpx; + overflow: hidden; + line-height: 42rpx; + white-space: nowrap; + text-overflow: ellipsis; +} +.discount{ + position: absolute; + width: 100rpx; + top:86rpx; + right:2rpx; +} +.info .sucess { + display: inline-block; + width: 123rpx !important; + /* overflow: hidden; */ + font-size: 26rpx; + color: #02c0ff; + letter-spacing: 0; + text-align: right; + line-height: 26px; +} + +.wait { + display: inline-block; + width: 123rpx !important; + overflow: visible!important; + font-size: 28rpx; + color: #ff4949; + letter-spacing: 0; + text-align: right; + line-height: 28rpx!important; +} + +.close { + display: inline-block; + width: 123rpx !important; + overflow: hidden; + font-size: 28rpx; + color: #999; + letter-spacing: 0; + text-align: right; + line-height: 28rpx; +} + +/* +.info view:nth-child(2), +.info view:nth-child(3), +.info view:nth-child(4) { + color: #333; + font-size: 24rpx; + +} */ + +.value { + font-size: 24rpx; + color: #999; + letter-spacing: 0; + padding-left: 4%; + line-height: 33rpx; +} + +.value text { + font-size: 24rpx; + color: #333; + letter-spacing: 0; + line-height: 33rpx; +} + +/* .info view:nth-child(2) text, .info view:nth-child(3) text { + font-size: 22rpx; +} */ + +.info view:nth-child(3) { + margin-top: 20rpx; +} + +.payment { + position: relative; + width: 92%; + height: 88rpx; + line-height: 88rpx; + padding: 0 4%; + display: flex; + justify-content: space-between; +} + +.payment view:nth-child(1) text:nth-child(1) { + font-size: 24rpx; + color: #1f2d3d; + letter-spacing: 0; +} + +.payment view:nth-child(1) text:nth-child(2) { + font-size: 28rpx; + color: #ff4949; + letter-spacing: 0; + margin-left: 10rpx; +} + +.payment view:nth-child(1) text:nth-child(3) { + font-size: 24rpx; + color: #b4b4b4; + padding-left: 18rpx; + text-decoration: line-through; +} + +.btn { + position: absolute; + top: 0; + bottom: 0; + margin: auto; + right: 20rpx; + width: 160rpx; + height: 52rpx; + line-height: 52rpx; + text-align: center; + color: #fff; + float: right; + font-size: 28rpx; + border: 2rpx solid #02c0ff; + border-radius: 10rpx; +} + +.payment view:nth-child(2) text { + font-size: 30rpx; + color: #02c0ff; +} + +.dingdan { + margin-top: 33rpx; +} + +.dingdan text:nth-of-type(1) { + display: block; + font-size: 34rpx; + color: #333; + letter-spacing: 0; + text-align: center; +} + +.dingdan text:nth-of-type(2) { + display: block; + font-size: 28rpx; + color: #999; + letter-spacing: 0; + text-align: center; +} + +.dingdan image { + display: block; + width: 300rpx; + height: 300rpx; + margin: 0 auto 16rpx; +} + +.loading { + text-align: center; + height: 80rpx; + line-height: 80rpx; + font-size: 26rpx; + color: #999; +} + +.loading image { + width: 60rpx; + height: 60rpx; + vertical-align: middle; + margin-right: 10rpx; +} +button::after{ border: none; } +.goback{ + width:400rpx!important; + height:80rpx; + line-height: 80rpx; + border-radius:10rpx; + background: orange; + color: #fff; + font-size: 32rpx; + margin-top: 20rpx; +} +.goback image{ + position: absolute; + width: 60rpx; + left: 0; + right: 0; + top: 0; + bottom: 0; + margin: auto; +}