sign.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view :style="[mainStyle]">
  3. <view class="top" v-if="detail">
  4. <view class="ddflex">
  5. <image :src="detail.pic" mode="aspectFill" class="act-img"></image>
  6. <view class="fflex">
  7. <view class="title tovers">{{detail.title}}</view>
  8. <view class="sta">
  9. <view class="area fflex ddflex">
  10. <image src="../static/images/sjico.png"></image>
  11. <view class="tover fflex">{{ getTimeText(detail.startTime,detail.endTime,true) }}</view>
  12. </view>
  13. <view class="ddflex" style="margin-top: 10rpx;">
  14. <view class="area fflex ddflex" v-if="detail.address">
  15. <image src="../static/images/dzico.png"></image>
  16. <view class="tover fflex">{{detail.address}}</view>
  17. </view>
  18. <!-- <view class="money" v-if="userinfovip.levelGrade>0&& !userinfovip.end">¥{{detail.vipMoney}}</view> -->
  19. <view class="money"><block v-if="price > 0">¥</block>{{price > 0 ? price : '免费'}}</view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <block v-if="step == 1">
  26. <view class="info">
  27. <view class="tit ddflex">
  28. <view class="fflex">报名信息<text style="color: #999;" v-if="options.personCount && price > 0">(最多添加{{options.personCount}}名人员)</text></view>
  29. <text>{{personList.length}}人</text>
  30. </view>
  31. <view class="add" @click="addSign()">+ 添加报名人</view>
  32. <view class="list">
  33. <view class="li ddflex" v-for="(item,index) in personList" :key="index">
  34. <image src="../static/images/userimg.png" mode="aspectFill" class="user"></image>
  35. <view class="fflex">
  36. <block v-for="it,idx in item" :key="idx">
  37. <block v-if="it.code == 'name'">{{it.value}}</block>
  38. <text v-if="it.code == 'phone'">{{it.value}}</text>
  39. </block>
  40. </view>
  41. <image src="../static/images/jian.png" class="jian" @click="delPerson(index)"></image>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="btn" @click="jumpStep(2)">下一步</view>
  46. <!-- <view class="btn" @click="jumpUrl('/match/signConfirm/signConfirm?id=' + detail.id + '&priceId=' + options.priceId)">下一步</view> -->
  47. </block>
  48. <block v-else>
  49. <view class="lists">
  50. <view class="li active" v-for="item,index in personPramas" :key="index">
  51. <view class="li-top ddflex">
  52. <view class="fflex">
  53. <block v-for="it,idx in item.child" :key="idx">
  54. <view class="name" v-if="it.code == 'name'">{{it.value}}</view>
  55. <view class="phone" v-if="it.code == 'phone'">{{it.value}}</view>
  56. </block>
  57. </view>
  58. <view :class="'li-opt ddflex'+(item.isShowChild ? ' active':'')" @click="showChild(index)">{{item.isShowChild ? '收起':'展开'}}<image src="../../static/pages/images/more.png" class="rico"></image></view>
  59. </view>
  60. <view class="li-bot" v-if="item.isShowChild">
  61. <block v-for="it,idx in item.child" :key="idx">
  62. <view class="lis ddflex" v-if="it.code != 'name' && it.code != 'phone'">
  63. <view class="fflex">{{it.title}}</view>
  64. <view v-if="it.code == 'sex'">{{it.value ? item.value == 1 ? '男' : '女' : '--'}}</view>
  65. <view v-else>{{it.value ? it.value : '--'}}</view>
  66. </view>
  67. </block>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- <view class="list">
  72. <view class="li ddflex" v-for="(item,index) in personList" :key="index">
  73. <view class="fflex">{{item.name}}</view>
  74. <text>{{item.phone}}</text>
  75. </view>
  76. </view> -->
  77. <view class="ming">
  78. <view class="tits-step2">活动说明</view>
  79. <view class="tips">
  80. <view>1、本活动由主办方处理退款事宜</view>
  81. <view>2、如需退款,请联系团长或客服</view>
  82. </view>
  83. </view>
  84. <view class="bot ddflex">
  85. <block v-if="money > 0">
  86. <view class="heji fflex">合计:<text class="yuan">¥</text><text>{{money}}</text></view>
  87. <view class="back-step" @click="jumpStep(1)">上一步</view>
  88. <view class="btn-step2" @click="createEnlist()">提交报名</view><!-- 原来的方法pay() -->
  89. </block>
  90. <block v-else>
  91. <view class="back-step" @click="jumpStep(1)">上一步</view>
  92. <view class="btn-step2 fflex" @click="createEnlist()">提交报名</view>
  93. </block>
  94. </view>
  95. </block>
  96. <!-- 添加报名信息 -->
  97. <view class="ceng" v-if="isAdd"></view>
  98. <view class="popup" v-if="isAdd">
  99. <view class="tits">姓名</view>
  100. <input placeholder="请输入真实姓名" placeholder-class="placeholder" class="ipt" @input="intName" />
  101. <view class="tits">手机号码</view>
  102. <input placeholder="请输入手机号码" placeholder-class="placeholder" class="ipt" @input="intPhone" />
  103. <view class="pop-btn ddflex">
  104. <view class="cancel" @click="cancel()">取消</view>
  105. <view class="save" @click="save()">保存</view>
  106. </view>
  107. </view>
  108. </view>
  109. </template>
  110. <script>
  111. const req = require('../../utils/request.js');
  112. const api = require('../../utils/api.js');
  113. const util = require('../../utils/util.js');
  114. const requsetmessage = require('../../utils/requestmessage.js');
  115. const app = getApp();
  116. export default {
  117. components: {
  118. },
  119. data() {
  120. return {
  121. mainStyle: app.globalData.mainStyle,
  122. isShow: false,
  123. options: {},
  124. detail: '',
  125. isAdd: false,
  126. personList: [],
  127. personPramas: [],
  128. name: '',
  129. phone: '',
  130. userinfovip: {},
  131. price: 0,
  132. step: 1,
  133. money: 0
  134. };
  135. },
  136. onLoad(options) {
  137. this.options = options;
  138. // if(req.getStorage('personList')){
  139. // this.personList = req.getStorage('personList')
  140. // }
  141. // if(req.getStorage('personPramas')) {
  142. // this.personPramas = req.getStorage('personPramas');
  143. // }
  144. },
  145. onShow() {
  146. this.price = req.getStorage('actPrice');
  147. this.getData(false);
  148. // this.getuserVip();
  149. console.log('personList==',this.personList)
  150. },
  151. onUnload() {
  152. },
  153. methods: {
  154. getTimeText(startTime,endTime,isText){
  155. return util.getTimeText(startTime,endTime,isText);
  156. },
  157. getData(isShow){
  158. req.getRequest('/api/match/detail',{id: this.options.id},res => {
  159. this.detail = res;
  160. this.isShow = true;
  161. },isShow);
  162. },
  163. getuserVip() {
  164. req.getRequest('/api/user/levelDetails', {}, data => {
  165. let expireTime = Array;
  166. if (data.expireTime) {
  167. expireTime = data.expireTime.split(" ");
  168. data.expireTime = data.expireTime.replace(/-/g, '/');
  169. } // 解决苹果不兼容---日期
  170. let nowTime = new Date().getTime();
  171. let endTime = new Date(data.expireTime).getTime();
  172. let times = parseInt((endTime - nowTime) / 1000); // var expireTime= new Date(data.expireTime)
  173. // console.log(times, nowTime, endTime, data.expireTime);
  174. this.userinfovip = data;
  175. if (times <= 0) {
  176. this.userinfovip.end = true;
  177. } else {
  178. this.userinfovip.end = false;
  179. }
  180. });
  181. },
  182. choose: function () {
  183. let freshen = false;
  184. this.$emit('freshen', {
  185. detail: freshen
  186. });
  187. },
  188. jumpUrl(url){
  189. if(this.personList && this.personList.length < 1) return req.msg('请添加报名人员');
  190. if(this.price > 0 && this.personList.length > this.options.personCount) return req.msg('最多添加' + this.options.personCount + '名人员')
  191. req.setStorage('personList',this.personList);
  192. // req.setStorage('personPramas',this.personPramas);
  193. uni.navigateTo({
  194. url: url
  195. })
  196. },
  197. addSign(){
  198. if(this.price > 0 && this.personList.length >= this.options.personCount) return req.msg('最多添加' + this.options.personCount + '名人员')
  199. req.setStorage('personList',this.personList);
  200. // req.setStorage('personPramas',this.personPramas);
  201. uni.navigateTo({
  202. url: '/match/form/index'
  203. })
  204. // this.isAdd = true;
  205. },
  206. cancel(){
  207. this.isAdd = false;
  208. },
  209. intName(e) {
  210. this.name = e.detail.value;
  211. },
  212. intPhone(e) {
  213. this.phone = e.detail.value;
  214. },
  215. save(){
  216. if(!this.name) return req.msg('请填写报名人员姓名');
  217. if(!this.phone) return req.msg('请填写报名人员手机号码');
  218. if(!util.isMobile(this.phone)) return req.msg('请填写正确的手机号码')
  219. let personList = this.personList;
  220. let arr = {
  221. name: this.name,
  222. phone: this.phone
  223. }
  224. this.personList = personList.concat(arr);
  225. req.setStorage('personList',this.personList)
  226. this.isAdd = false;
  227. },
  228. delPerson(index){
  229. // let cur;
  230. // this.personList.map((it,idx)=>{
  231. // if(index == idx) cur = it;
  232. // })
  233. // console.log('cur===',cur)
  234. this.personList.splice(index,1);
  235. // this.personPramas.map((it,idx)=>{
  236. // it.map(its=>{
  237. // if(cur[its.code] == its.value) this.personPramas.splice(idx,1)
  238. // })
  239. // })
  240. req.setStorage('personList',this.personList)
  241. // req.setStorage('personPramas',this.personPramas)
  242. this.$forceUpdate();
  243. },
  244. jumpStep(step){
  245. if(step == 2){
  246. if(this.personList && this.personList.length < 1) return req.msg('请添加报名人员');
  247. if(this.price > 0 && this.personList.length > this.options.personCount) return req.msg('最多添加' + this.options.personCount + '名人员')
  248. this.step = 2;
  249. let arr = [];
  250. this.personList.map(it=>{
  251. let obj = {
  252. isShowChild: false,
  253. child: it
  254. }
  255. arr.push(obj);
  256. })
  257. this.personPramas = arr;
  258. this.money = req.getStorage('actPrice');
  259. }else{
  260. this.step = 1;
  261. }
  262. },
  263. showChild(index){
  264. if(this.personPramas[index].isShowChild){
  265. this.personPramas[index].isShowChild = false;
  266. }else{
  267. console.log('未展开')
  268. this.personPramas.map((it,idx)=>{
  269. if(index == idx) it.isShowChild = true;
  270. else it.isShowChild = false;
  271. return it;
  272. })
  273. }
  274. this.$forceUpdate();
  275. },
  276. async createEnlist(){
  277. let pa = {
  278. matchId: this.detail.id,
  279. money: this.money,
  280. id: this.options.priceId
  281. }
  282. pa.params = JSON.stringify(this.personList);
  283. // #ifdef MP-WEIXIN
  284. await requsetmessage.remindActivity().then(res => {});
  285. // #endif
  286. req.postRequest(api.enlist_create,pa,async res=>{
  287. this.enlistLaunchCrowd(res);
  288. })
  289. },
  290. enlistLaunchCrowd(enlistId){
  291. let pa = {
  292. enlistId: enlistId,
  293. type: 2
  294. }
  295. req.postRequest(api.enlist_launchCrowd,pa,async data=>{
  296. await this.payOrder(data)
  297. })
  298. },
  299. payOrder(id){
  300. req.payOrders(id,success =>{
  301. uni.redirectTo({
  302. url: '/match/success/success?id=' + this.detail.id
  303. })
  304. })
  305. },
  306. }
  307. };
  308. </script>
  309. <style>page{background: #F6F6F6;}</style>
  310. <style>
  311. @import "./sign.css";
  312. </style>