activityDetail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. <template>
  2. <view class="flex-col page">
  3. <view class="flex-col content">
  4. <view class="out1">
  5. <view class="flex-col top">
  6. <view class="flex-row title">
  7. <text>{{ activity.title }}</text>
  8. </view>
  9. <view class="flex-row price">
  10. <text v-if="isShare">¥{{ activity.sharePrice }}</text>
  11. <text
  12. :style="{textDecorationLine:(isShare ?'line-through' :'none'),color:(isShare ? '#878787':''), fontSize:(isShare ? '24rpx':'') }">
  13. ¥{{ activity.salePrice }}
  14. </text>
  15. </view>
  16. <view class="flex-row">
  17. <view class="activityKey ">
  18. <text>购买时间:</text>
  19. </view>
  20. <view>
  21. <text v-if="activity.valid == 2">{{ activity.validBeginTime.substring(0, 10) }} 至
  22. {{ activity.validEndTime.substring(0, 10) }}
  23. </text>
  24. <text v-else>长期有效</text>
  25. </view>
  26. </view>
  27. <view class="flex-row">
  28. <view class="activityKey">
  29. <text>活动门店:</text>
  30. </view>
  31. <view class="activityValue">
  32. <text>{{ activity.partStoreName || '' }}</text>
  33. </view>
  34. </view>
  35. <view class="flex-row">
  36. <view class="activityKey ">
  37. <text>活动描述:</text>
  38. </view>
  39. <view class="activityValue">
  40. <text>{{ activity.description }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="out2" v-if="activity.couponList">
  46. <view class="flex-col ticket">
  47. <view class="flex-row justify-center title">
  48. <text>赠送优惠券</text>
  49. </view>
  50. <view v-for="(item,index) in activity.couponList">
  51. <view class="flex-row ticketList">
  52. <view class="row-list flex-row justify-start">
  53. <view class="h-text flex-col justify-center ">
  54. <view class="money">
  55. <text class="money" v-if="item.discountsType == 2">{{ item.discount }}折</text>
  56. <text class="money" v-else>{{ `减` + item.discountsPrice }}</text>
  57. </view>
  58. <view class="desc">
  59. <text>满{{ item.reachPrice }}可用</text>
  60. </view>
  61. </view>
  62. <view class="h-center-content flex-col justify-around">
  63. <view class="h-value">
  64. <text>{{ item.name }}</text>
  65. </view>
  66. <view class="itemTitle">
  67. 使用次数:{{ item.degree }}
  68. </view>
  69. <view class="itemTitle">
  70. <text v-if="item.validType == 1">领取后{{ item.effectiveDays }}天内有效</text>
  71. <view v-else>
  72. <view>使用期限:{{ item.startTime.substring(0, 10) }}</view>
  73. <view> 至 {{ item.endTime.substring(0, 10) }}</view>
  74. </view>
  75. </view>
  76. <view class="itemTitle flex-row">
  77. <text @click.stop="showRemark(item)">使用规则</text>
  78. <u-icon v-if="item.id == showRemarkId" name="arrow-down-fill" color="" size="12"></u-icon>
  79. <u-icon v-else name="play-right-fill" color="" size="12"></u-icon>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <view v-if="showRemarkId == item.id" class="remark" style="text-indent:unset">
  85. <view>
  86. 可用门店:
  87. <text>{{ item.useStoreDesc }}</text>
  88. </view>
  89. <view>
  90. 适用项目:
  91. <text>{{ item.useServiceDesc }}</text>
  92. </view>
  93. <view v-if="item.remark !=null">
  94. 使用说明:
  95. <text>{{ item.remark }}</text>
  96. </view>
  97. <text v-else class="remarkText">该优惠券暂无使用说明</text>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <view class="out2" v-if="activity.equityList">
  103. <view class="flex-col ticket">
  104. <view class="flex-row justify-center title">
  105. <text>赠送权益卡</text>
  106. </view>
  107. <view v-for="(i,index) in activity.equityList">
  108. <view class="flex-row ticketList">
  109. <view class="h-text flex-col justify-center ">
  110. <text class="money">{{ i.faceValue }}</text>
  111. <text class="desc">权益价</text>
  112. </view>
  113. <view class="h-center-content flex-col justify-around">
  114. <view class="h-value">
  115. <text>{{ i.title }}</text>
  116. </view>
  117. <view class="ticketMsg">
  118. 领取后{{ i.effectiveDays }}天内有效
  119. </view>
  120. <view class="itemTitle flex-row">
  121. <text @click.stop="showRemark(i)">使用规则</text>
  122. <u-icon v-if="i.id == showRemarkId" name="arrow-down-fill" color="" size="12"></u-icon>
  123. <u-icon v-else name="play-right-fill" color="" size="12"></u-icon>
  124. </view>
  125. </view>
  126. </view>
  127. <view v-if="showRemarkId == i.id" class="remark" style="text-indent:unset">
  128. <view>
  129. 可用门店:
  130. <text>{{ i.useStoreDesc }}</text>
  131. </view>
  132. <view v-if="i.description !=null">
  133. 使用说明:
  134. <text>{{ i.description }}</text>
  135. </view>
  136. <text v-else class="remarkText">该权益卡暂无使用说明</text>
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. <view class="out2" v-if="activity.rechargeList">
  142. <view class="flex-col ticket">
  143. <view class="flex-row justify-center title">
  144. <text>赠送储值卡</text>
  145. </view>
  146. <view class="flex-row ticketList" v-for="(i,index) in activity.rechargeList">
  147. <view class="h-text flex-col justify-center ">
  148. <text class="money">{{ i.reachPrice }}</text>
  149. <text class="desc">储值额度</text>
  150. </view>
  151. <view class="h-center-content flex-col justify-around">
  152. <view class="h-value">
  153. <text>{{ i.name }}</text>
  154. </view>
  155. </view>
  156. </view>
  157. </view>
  158. </view>
  159. </view>
  160. <view v-if="!isShareMax" class="flex-row justify-center inBtnView">
  161. <view class="inBtn" @click="beforeCommitOrder" v-if="!isActivityCheck">立即参与</view>
  162. <view class="inBtn" v-else>已参与</view>
  163. </view>
  164. <myPay ref="myPay" :selectBlPay="userInfo.balance *1 >= totalAmount *1" :balance="userInfo.balance"
  165. :totalAmount="totalAmount" :lovePay="false" :blPay="false"
  166. :orderNo="subOrderNo" @payResult="payResult" @improperClose="improperClose"></myPay>
  167. <!-- <view>-->
  168. <!-- <u-picker :show="show" title="选择服务对象" :closeOnClickOverlay="true" @close="show = false"-->
  169. <!-- :columns="serviceObjectList"-->
  170. <!-- keyName="nickName" @cancel="show = false" @confirm="confirm"></u-picker>-->
  171. <!-- </view>-->
  172. <uni-popup ref="popup" type="bottom">
  173. <view class="addService">
  174. <view class="flex-row justify-around">
  175. <view :class="[type == 2 ? 'confirmButton' : 'cancelButton']" @click="clickPopupTitleBtn(2)">
  176. <text>选择推荐门店</text>
  177. </view>
  178. <view :class="[type == 1 ? 'confirmButton' : 'cancelButton']" @click="clickPopupTitleBtn(1)">
  179. <text>选择服务对象</text>
  180. </view>
  181. </view>
  182. <scroll-view class="scrollY" scroll-y>
  183. <view v-if="type == 1" class="flex-row objectItem" v-for="(item,index) in serviceObjectList" :key="index" :class="{'vBackGround': selectServiceObjectIndex === index}" @click="selectServiceObjectIndex = index">
  184. <image class="objectImage" :src="item.facePhotoUrl || '/static/ud4.png'"></image>
  185. <view class="flex-col objectName ">
  186. <text>{{ item.nickName }}</text>
  187. </view>
  188. <image v-if="selectServiceObjectIndex === index" class="vImage"
  189. src="/static/index/xuanzhong.png"></image>
  190. </view>
  191. <view v-if="type == 2" class="flex-row objectItem" v-for="(item,index) in storeList" :key="index" :class="{'vBackGround': selectStoreIndex === index}" @click="setSelectStoreIndex(index)">
  192. <view class="flex-col objectName ">
  193. <text>{{ item.name }}</text>
  194. </view>
  195. <image v-if="item[index].id === storeId" class="vImage"
  196. src="/static/index/xuanzhong.png"></image>
  197. </view>
  198. </scroll-view>
  199. <view class="flex-row justify-around">
  200. <view class="cancelButton" @click="closeSelectServiceObjectPopup">
  201. <text>取消</text>
  202. </view>
  203. <view class="confirmButton" @click="confirm(serviceObjectList[selectServiceObjectIndex])">
  204. <text>确定</text>
  205. </view>
  206. </view>
  207. </view>
  208. </uni-popup>
  209. </view>
  210. </template>
  211. <script>
  212. import myPay from '../../components/pay/pay';
  213. export default {
  214. components: {
  215. myPay
  216. },
  217. data() {
  218. return {
  219. type:2,
  220. storeList: [],
  221. selectServiceObjectIndex: -1,
  222. selectStoreIndex: -1,
  223. showRemarkId: '',
  224. userInfo: {},
  225. subOrderNo: '',
  226. id: '',
  227. storeId: '',
  228. userId: '',
  229. techNo: '',
  230. activity: {},
  231. requestStatus: false,
  232. isActivityCheck: true, //是否参与过该活动
  233. serviceObjectList: [],
  234. show: false,
  235. serviceObjectId: null,
  236. isShare: false,
  237. inviteUserId: null,
  238. inviteOrderId: null,
  239. inviteActivityId:null,
  240. isShareMax: false,
  241. renewServiceObjectId:null,
  242. upgradeEquityCardId:null
  243. }
  244. },
  245. computed: {
  246. totalAmount() {
  247. if (this.isShare) {
  248. return this.activity.sharePrice
  249. } else {
  250. return this.activity.salePrice
  251. }
  252. }
  253. },
  254. onLoad(e) {
  255. console.log('+++++++++++e+++++++++++++',e)
  256. if (e.renewServiceObjectId){
  257. this.renewServiceObjectId = e.renewServiceObjectId
  258. }
  259. if (e.upgradeEquityCardId){
  260. this.upgradeEquityCardId = e.upgradeEquityCardId
  261. }
  262. if (e.id) {
  263. this.id = e.id
  264. console.log('上一个页面传递过来的活动ID===>', this.id)
  265. }
  266. if (e.inviteUserId) {
  267. console.log(e)
  268. this.id = e.activityId
  269. this.inviteUserId = e.inviteUserId
  270. this.inviteOrderId = e.inviteOrderId
  271. this.inviteActivityId = e.inviteActivityId
  272. this.isShare = true
  273. }
  274. // 扫技师端携带的参数,已存在缓存中
  275. let promotionParam = uni.getStorageSync('promotionParam')
  276. if (promotionParam) {
  277. console.log('获取到技师的二维码数据', promotionParam)
  278. this.storeId = promotionParam.storeId
  279. this.techNo = promotionParam.techNo
  280. } else {
  281. let storeParam = uni.getStorageSync('storeParam')
  282. // console.log('获取到门店的二维码数据',param)
  283. this.storeId = storeParam.storeId
  284. }
  285. if (e.q) {
  286. //扫店长端二维码进来的活动参数
  287. const q = decodeURIComponent(e.q)
  288. let a = q.split('?')
  289. let b = a[1].split('&')
  290. let param = {} //技师端分享过来的参数
  291. for (let i = 0; i < b.length; i++) {
  292. param[b[i].split('=')[0]] = b[i].split('=')[1]
  293. }
  294. this.id = param.activityId
  295. this.storeId = param.storeId
  296. this.techNo = ''
  297. console.log("扫店长端二维码进来的活动参数===》", param)
  298. uni.setStorageSync('storeParam', param)
  299. uni.removeStorageSync('promotionParam');
  300. }
  301. this.userInfo = uni.getStorageSync('userInfo')
  302. this.activityDetail()
  303. this.activityCheck()
  304. },
  305. onShow() {
  306. this.userInfo = uni.getStorageSync('userInfo')
  307. },
  308. methods: {
  309. setSelectStoreIndex(index){
  310. if (this.selectStoreIndex === index){
  311. this.storeId = null
  312. this.selectStoreIndex = -1
  313. }else {
  314. this.storeId = this.storeList[index].id
  315. this.selectStoreIndex = index
  316. }
  317. },
  318. clickPopupTitleBtn(type){
  319. this.type = type
  320. },
  321. showRemark(item) {
  322. if (this.showRemarkId == item.id) {
  323. this.showRemarkId = ''
  324. } else {
  325. this.showRemarkId = item.id
  326. }
  327. },
  328. getImgUrlByBannerOssId(items) {
  329. for (let i = 0; i < items.length; i++) {
  330. if (items[i].facePhoto) {
  331. this.$api.getImgUrlByOssId({ossId: items[i].facePhoto}).then(res => {
  332. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  333. this.$set(this.serviceObjectList, i, items[i])
  334. })
  335. }
  336. }
  337. },
  338. // 查询服务对像信息列表
  339. listServiceObject() {
  340. return this.$api.listServiceObject(this.reqParm).then((res) => {
  341. let serviceObjectList = [];
  342. res.data.data.forEach(i => {
  343. if (this.renewServiceObjectId){
  344. if (i.isSelf != 1) {
  345. if (this.renewServiceObjectId == i.id){
  346. serviceObjectList.push(i);
  347. }
  348. }
  349. }else {
  350. if (i.isSelf != 1) {
  351. serviceObjectList.push(i);
  352. }
  353. }
  354. });
  355. this.$set(this.serviceObjectList, 0, serviceObjectList);
  356. this.getImgUrlByBannerOssId(this.serviceObjectList[0]);
  357. console.log('执行了+++++++++++++++++++', this.serviceObjectList);
  358. if (this.activity.isAddServiceObject == 1 && serviceObjectList.length === 0) {
  359. // 无服务对象:执行跳转逻辑,返回 false 表示不继续后续操作
  360. uni.showToast({
  361. duration: 1500, // 与 setTimeout 时间一致,避免提示残留
  362. title: '当前账号没有服务对象,即将跳转服务对象绑定',
  363. icon: 'none',
  364. });
  365. setTimeout(() => {
  366. uni.hideToast();
  367. uni.navigateTo({
  368. url: '/myPages/serviceObjectFaceAuth/index'
  369. });
  370. }, 1500);
  371. return false; // 关键:告诉 beforeCommitOrder 不需要继续执行
  372. }
  373. // 有服务对象:返回 true 表示可以继续后续操作
  374. return true;
  375. }).catch((err) => {
  376. console.error('获取服务对象列表失败', err);
  377. uni.showToast({
  378. title: '获取服务信息失败,请重试',
  379. icon: 'none',
  380. duration: 2000
  381. });
  382. return false; // 接口失败也不继续后续逻辑
  383. });
  384. },
  385. closeSelectServiceObjectPopup() {
  386. this.selectServiceObjectIndex = -1
  387. this.$refs.popup.close()
  388. },
  389. //支付结果回调
  390. payResult(e) {
  391. console.log(e)
  392. if (e.payResult) {
  393. uni.showToast({
  394. duration: 2000,
  395. title: '支付成功!'
  396. });
  397. this.isActivityCheck = true
  398. //清除技师端缓存的参数
  399. uni.removeStorageSync('promotionParam');
  400. //清除技店长端缓存的参数
  401. uni.removeStorageSync('storeParam');
  402. setTimeout(() => {
  403. uni.reLaunch({
  404. url: '/myPages/myActivity/myActivity'
  405. })
  406. }, 2000)
  407. } else {
  408. uni.showToast({
  409. duration: 2000,
  410. title: '支付失败!',
  411. icon: 'error'
  412. });
  413. }
  414. },
  415. //支付弹窗关闭回调
  416. improperClose() {
  417. },
  418. async beforeCommitOrder() {
  419. try {
  420. // 等待 listServiceObject 完全执行(包括数据处理、弹窗提示注册),拿到是否继续的标记
  421. const isContinue = await this.listServiceObject();
  422. // 关键:如果不需要继续(无服务对象/接口失败),直接终止,不执行后续 popup 逻辑
  423. if (!isContinue) return;
  424. // 以下逻辑仅在「有服务对象」时才执行
  425. if (!this.userInfo.phone) {
  426. uni.showModal({
  427. title: '温馨提示',
  428. content: '请先绑定手机号',
  429. success: res => {
  430. if (res.confirm) {
  431. uni.navigateTo({
  432. url: '/myPages/setting/setting-telphone',
  433. });
  434. }
  435. }
  436. });
  437. return;
  438. }
  439. if (this.activity.isAddServiceObject == 1) {
  440. this.$refs.popup.open(); // 只有有服务对象+手机号已绑定,才打开 popup
  441. } else {
  442. this.commitOrder();
  443. }
  444. } catch (err) {
  445. uni.showToast({
  446. title: '操作失败,请重试',
  447. icon: 'none',
  448. duration: 2000
  449. });
  450. }
  451. },
  452. confirm(e) {
  453. // console.log(e)
  454. // this.serviceObjectId = e.value[0].id
  455. console.log(e)
  456. if (!e) {
  457. uni.showToast({
  458. duration: 2000,
  459. title: '请选择一个服务对象',
  460. icon: 'none'
  461. });
  462. return
  463. }
  464. this.serviceObjectId = e.id
  465. // this.show = false
  466. this.$refs.popup.close()
  467. this.commitOrder()
  468. },
  469. //提交订单
  470. commitOrder() {
  471. // if (this.subOrderNo){
  472. // this.$refs.myPay.openPopup()
  473. // }else {
  474. if (this.requestStatus) {
  475. return;
  476. }
  477. this.requestStatus = true
  478. uni.showLoading({
  479. title: '加载中'
  480. });
  481. this.$api.commonGeneralOrder({
  482. orderType: 7,
  483. serviceObjectId: this.serviceObjectId,
  484. activityId: this.activity.id,
  485. storeId: this.storeId ,
  486. inviteUserId: this.inviteUserId,
  487. inviteOrderId: this.inviteOrderId,
  488. inviteActivityId: this.inviteActivityId,
  489. techNo: this.techNo,
  490. upgradeEquityCardId: this.upgradeEquityCardId
  491. }).then(res => {
  492. console.log('++++++++++++++++++订单提交+++++++++++', res)
  493. uni.hideLoading();
  494. this.subOrderNo = res.data.data.orderNo
  495. if (this.isShare) {
  496. if (this.activity.sharePrice * 1 > 0) {
  497. this.$refs.myPay.openPopup()
  498. } else {
  499. uni.showToast({
  500. duration: 2000,
  501. title: '活动参与成功!'
  502. });
  503. //清除技师端缓存的参数
  504. uni.removeStorageSync('promotionParam');
  505. //清除技店长端缓存的参数
  506. uni.removeStorageSync('storeParam');
  507. this.isActivityCheck = true
  508. }
  509. } else {
  510. if (this.activity.salePrice * 1 > 0) {
  511. this.$refs.myPay.openPopup()
  512. } else {
  513. uni.showToast({
  514. duration: 2000,
  515. title: '活动参与成功!'
  516. });
  517. //清除技师端缓存的参数
  518. uni.removeStorageSync('promotionParam');
  519. //清除技店长端缓存的参数
  520. uni.removeStorageSync('storeParam');
  521. this.isActivityCheck = true
  522. }
  523. }
  524. this.requestStatus = false
  525. }).catch(err => {
  526. this.requestStatus = false
  527. })
  528. // }
  529. },
  530. activityDetail() {
  531. console.log(this.id, '活动ID')
  532. const data = {
  533. id: this.id,
  534. inviteUserId:this.inviteUserId,
  535. inviteOrderId:this.inviteOrderId,
  536. }
  537. if (this.inviteActivityId){
  538. data.inviteActivityId = this.inviteActivityId
  539. }
  540. this.$api.activityDetail(data).then(res => {
  541. console.log(res)
  542. this.activity = res.data.data
  543. let ids = this.activity.partStoreIds.split(',')
  544. let names = this.activity.partStoreName.split(',')
  545. console.log(ids,names)
  546. for (let i = 0; i < ids.length; i++) {
  547. let store = {
  548. id: ids[i],
  549. name: names[i]
  550. }
  551. this.storeList.push(store)
  552. }
  553. console.log(this.storeList,'+++++++++store_list++++++++++')
  554. this.$set(this.activity)
  555. if (this.isShare) {
  556. console.log(this.activity)
  557. if (this.activity.shareMax > 0 && this.activity.shareMax <= this.activity.shareCount) {
  558. uni.showToast({
  559. duration: 3000,
  560. title: '当前链接已经超出最大分享次数',
  561. icon: 'none'
  562. });
  563. this.isShareMax = true
  564. }
  565. }
  566. })
  567. },
  568. activityCheck() {
  569. this.$api.activityCheck({activityId: this.id,}).then(res => {
  570. console.log(res)
  571. this.isActivityCheck = res.data.data
  572. })
  573. }
  574. }
  575. }
  576. </script>
  577. <style lang="scss" scoped>
  578. @import '/common/css/common.css';
  579. @import './index.rpx.scss';
  580. </style>