index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <view class="page" :style="{ 'height': equityList.length > 0 ? windowHeight : windowHeight1 }">
  3. <view class="centent">
  4. <view class="flex-col" v-if="equityList.length === 0">
  5. <view class="flex-row justify-center">
  6. <image class="empty" src="/static/imageIcon/empty.png" mode="widthFix"></image>
  7. </view>
  8. <view class="emptyText flex-row justify-center">
  9. <text>暂无内容</text>
  10. </view>
  11. </view>
  12. <scroll-view v-else scroll-y :style="{ 'height': windowHeight }">
  13. <view class="flex-col row-list" v-for="(item, index) in equityList" :key="index">
  14. <view class="flex-row justify-start">
  15. <view class="h-text flex-col justify-center ">
  16. <view class="money">
  17. <text>{{ item.salePrice }}</text>
  18. </view>
  19. <!-- <view class="desc">-->
  20. <!-- <text>{{item.title}}</text>-->
  21. <!-- </view>-->
  22. </view>
  23. <view class="flex-col">
  24. <view class="h-value">
  25. <text>{{ item.title }}</text>
  26. </view>
  27. <view class="flex-row">
  28. <view class="h-center-content flex-col justify-around">
  29. <view class="title">
  30. 适用项目:{{ item.serviceProjectName || '' }}
  31. </view>
  32. <view class="title">
  33. 适用门店:{{ item.useStoreDesc || '' }}
  34. </view>
  35. <view class="title">
  36. 有效天数:{{ item.effectiveDays }}
  37. </view>
  38. <view class="title flex-row" @click.stop="showRemark(item)">
  39. <text>使用规则</text>
  40. <u-icon v-if="item.id == showRemarkId" name="arrow-down-fill" color="" size="12"></u-icon>
  41. <u-icon v-else name="play-right-fill" color="" size="12"></u-icon>
  42. </view>
  43. </view>
  44. <view class="h-right-content flex-col justify-center ">
  45. <view class="btn" @click="payRights(item)">
  46. <text>购买</text>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view v-if="showRemarkId == item.id" class="remark" style="text-indent:unset">
  53. <view v-if="item.unavailableWeeklyTimes || item.unavailableTimeRanges">
  54. 不可用日期:
  55. <view v-if="item.unavailableWeeklyTimes">{{ parseWeeklyTimes(item.unavailableWeeklyTimes) }}</view>
  56. <view v-if="item.unavailableTimeRanges">{{ parseTimeRanges(item.unavailableTimeRanges) }}</view>
  57. </view>
  58. <view v-if="item.delayEffectiveDays > 0">
  59. 生效时间:
  60. <text>购买后{{item.delayEffectiveDays}}天生效</text>
  61. </view>
  62. <view v-if="item.description !=null">
  63. 使用说明:
  64. <text>{{ item.description }}</text>
  65. </view>
  66. <text v-else class="remarkText">该优惠券暂无使用说明</text>
  67. </view>
  68. </view>
  69. </scroll-view>
  70. </view>
  71. <view class="btnTitle flex-row" v-if="equityList.length > 0">
  72. <u-icon v-if="selectIcon" name="checkmark-circle-fill" color="#FFE52C" size="18" @click="selectChange"></u-icon>
  73. <u-icon v-else name="/static/order/ud9.png" color="#FFE52C" size="18" @click="selectChange"></u-icon>
  74. <text :style="{ 'margin-left': '10rpx' }">请阅读并同意</text>
  75. <text :style="{ 'color': 'red' }" @click="goTermsOfService">《娇骄儿权益服务协议》</text>
  76. </view>
  77. <uni-popup ref="popup" :catchtouchmove="true" :animation="false" type="bottom">
  78. <view class=" payView">
  79. <view class="flex-row justify-between">
  80. <text class="payType">微信支付</text>
  81. <image class="x" src="/static/common/ox.png" @click="closePayPopup"></image>
  82. </view>
  83. <view class="payItem flex-row justify-between" @click="payItem(2)">
  84. <view class="flex-row">
  85. <u-icon name="weixin-circle-fill" color="#38db38" size="36"></u-icon>
  86. <view class="payName flex-col justify-center">
  87. <text>微信支付</text>
  88. </view>
  89. </view>
  90. <view class="flex-col justify-center">
  91. <view v-if="curServiceTab === 2">
  92. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  93. </view>
  94. <view v-else>
  95. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  96. </view>
  97. </view>
  98. </view>
  99. <view class="commitBtn" @click="commonGeneralOrder">
  100. <text>确定</text>
  101. </view>
  102. </view>
  103. </uni-popup>
  104. <!-- <u-picker :show="show" title="选择服务对象" :closeOnClickOverlay="true" @close="show = false" :columns="serviceObjectList"-->
  105. <!-- keyName="nickName" @cancel="show = false" @confirm="confirm"></u-picker>-->
  106. <uni-popup ref="selectObjectPopup" type="bottom">
  107. <view class="addService">
  108. <view class="popupTitle">
  109. <text>选择服务对象</text>
  110. </view>
  111. <scroll-view class="scrollY" scroll-y>
  112. <view class="flex-row objectItem" :class="{'vBackGround': selectServiceObjectIndex === index}"
  113. v-for="(item,index) in serviceObjectList" :key="index"
  114. @click="selectServiceObjectIndex = index">
  115. <image class="objectImage" :src="item.facePhotoUrl || '/static/ud4.png'"></image>
  116. <view class="flex-col objectName ">
  117. <text>{{ item.nickName }}</text>
  118. </view>
  119. <image v-if="selectServiceObjectIndex === index" class="vImage"
  120. src="/static/index/xuanzhong.png"></image>
  121. </view>
  122. </scroll-view>
  123. <view class="flex-row justify-around">
  124. <view class="cancelButton" @click="closeSelectServiceObjectPopup">
  125. <text>取消</text>
  126. </view>
  127. <view class="confirmButton" @click="confirm(serviceObjectList[selectServiceObjectIndex])">
  128. <text>确定</text>
  129. </view>
  130. </view>
  131. </view>
  132. </uni-popup>
  133. </view>
  134. </template>
  135. <script>
  136. export default {
  137. data() {
  138. return {
  139. selectServiceObjectIndex: -1,
  140. selectIcon: '',
  141. windowHeight: '',
  142. windowHeight1: '',
  143. show: false,
  144. curServiceTab: 2,
  145. orderRights: {},
  146. userInfo: {},
  147. serviceObjectList: [],
  148. serviceObjectIndex: 0,
  149. equityList: [],
  150. serviceObject: {},
  151. orderNo: '',
  152. showRemarkId: '',
  153. };
  154. },
  155. computed: {
  156. // 解析 unavailableWeeklyTimes,将 "3,4,5" 转换为 ["星期二", "星期三", "星期四"]
  157. parseWeeklyTimes() {
  158. return function(times) {
  159. if (!times) return '';
  160. const arr = times.split(',');
  161. const weekMap = {
  162. '1': '星期日',
  163. '2': '星期一',
  164. '3': '星期二',
  165. '4': '星期三',
  166. '5': '星期四',
  167. '6': '星期五',
  168. '7': '星期六'
  169. };
  170. return arr.map(item => weekMap[item]).join('、');
  171. };
  172. },
  173. // 解析 unavailableTimeRanges,将 JSON 字符串转换为可读格式
  174. parseTimeRanges() {
  175. return function(ranges) {
  176. if (!ranges) return '';
  177. try {
  178. const arr = JSON.parse(ranges);
  179. return arr.map(item => {
  180. const begin = item.beginTime.split(' ')[0];
  181. const end = item.endTime.split(' ')[0];
  182. return `${begin} - ${end}`;
  183. }).join(';');
  184. } catch (e) {
  185. return '';
  186. }
  187. };
  188. }
  189. },
  190. //unavailableTimeRanges: "[{"beginTime":"2026-02-04 00:00:00","endTime":"2026-02-08 23:59:59"}]"
  191. // unavailableWeeklyTimes: "3,4,5"
  192. onLoad(option) {
  193. let sysInfo = uni.getSystemInfoSync()
  194. this.windowHeight = sysInfo.windowHeight - 50 + 'px'//除标题栏栏外的屏幕可用高度
  195. this.windowHeight1 = sysInfo.windowHeight + 'px'//除标题栏栏外的屏幕可用高度
  196. },
  197. onShow() {
  198. this.userInfo = uni.getStorageSync('userInfo')
  199. this.listServiceObject()
  200. this.equityCardList()
  201. },
  202. methods: {
  203. showRemark(item) {
  204. if (this.showRemarkId == item.id) {
  205. this.showRemarkId = ''
  206. } else {
  207. this.showRemarkId = item.id
  208. }
  209. },
  210. goTermsOfService() {
  211. uni.navigateTo({
  212. url: '/myPages/TermsOfService/index?name=' + '娇骄儿权益服务协议' + '&type=' + 4
  213. })
  214. },
  215. closeSelectServiceObjectPopup() {
  216. this.selectServiceObjectIndex = -1
  217. this.$refs.selectObjectPopup.close()
  218. },
  219. selectChange() {
  220. this.selectIcon = !this.selectIcon
  221. },
  222. getImgUrlByBannerOssId(items) {
  223. for (let i = 0; i < items.length; i++) {
  224. if (items[i].facePhoto) {
  225. this.$api.getImgUrlByOssId({ossId: items[i].facePhoto}).then(res => {
  226. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  227. this.$set(this.serviceObjectList, i, items[i])
  228. })
  229. }
  230. }
  231. },
  232. commonGeneralOrder() {
  233. let param = uni.getStorageSync('promotionParam')
  234. console.log('获取到技师的二维码数据', param)
  235. if (!param) {
  236. console.log('获取到门店的二维码数据', param)
  237. param = uni.getStorageSync('storeParam')
  238. }
  239. this.$refs.popup.close()
  240. this.$api.commonGeneralOrder({
  241. ...param,
  242. orderType: 5,
  243. serviceObjectId: this.serviceObject.id,
  244. equityCardId: this.orderRights.id
  245. }).then(res => {
  246. this.orderNo = res.data.data.orderNo
  247. if (this.curServiceTab === 1) {
  248. //开启余额支付
  249. this.balancePay()
  250. }
  251. if (this.curServiceTab === 2) {
  252. //调微信支付
  253. this.wechatPay()
  254. }
  255. })
  256. },
  257. //余额支付
  258. balancePay() {
  259. let that = this;
  260. this.$api.balancePay({
  261. orderNo: this.orderNo,
  262. password: ''
  263. }).then((res) => {
  264. uni.showToast({
  265. title: '支付成功!'
  266. });
  267. this.getUserInfo()
  268. })
  269. },
  270. wechatPay() {
  271. let that = this;
  272. // 发起微信支付
  273. this.$api.wechatPay({
  274. orderNo: this.orderNo
  275. }).then((res) => {
  276. var param = res.data.data;
  277. uni.requestPayment({
  278. appId: param.appid,
  279. timeStamp: param.timestamp + "",
  280. nonceStr: param.noncestr,
  281. package: "prepay_id=" + param.prepayid,
  282. signType: "RSA",
  283. paySign: param.sign,
  284. success: res => {
  285. uni.showToast({
  286. title: '支付成功!'
  287. });
  288. setTimeout(() => {
  289. uni.navigateTo({
  290. url: '/storePages/myRights/index'
  291. });
  292. }, 2000)
  293. },
  294. fail: res => {
  295. console.log(res)
  296. uni.showModal({
  297. content: '支付失败',
  298. showCancel: false
  299. });
  300. }
  301. });
  302. })
  303. },
  304. getUserInfo() {
  305. this.$api.getUserInfo().then(res => {
  306. console.log('++++++++++++获取用户信息++++++++++++++++++', res)
  307. uni.setStorageSync('userInfo', res.data.data)
  308. this.userInfo = res.data.data
  309. })
  310. },
  311. confirm(e) {
  312. console.log(e)
  313. if (!e) {
  314. uni.showToast({
  315. duration: 2000,
  316. title: '请选择一个服务对象',
  317. icon: 'none'
  318. });
  319. return
  320. }
  321. // this.serviceObject = e.value[0]
  322. this.serviceObject = e
  323. // this.show = false
  324. this.$refs.selectObjectPopup.close()
  325. this.$refs.popup.open()
  326. },
  327. equityCardList() {
  328. this.$api.equityCardList().then(res => {
  329. console.log(res)
  330. this.equityList = res.data.data
  331. })
  332. },
  333. // 查询服务对像信息列表
  334. listServiceObject() {
  335. let serviceObjectList = []
  336. this.$api.listServiceObject(this.reqParm).then((res) => {
  337. res.data.data.forEach(i => {
  338. if (i.isSelf != 1) {
  339. serviceObjectList.push(i)
  340. }
  341. })
  342. this.serviceObjectList[0] = serviceObjectList
  343. this.getImgUrlByBannerOssId(this.serviceObjectList[0]);
  344. })
  345. },
  346. closePayPopup() {
  347. this.$refs.popup.close()
  348. },
  349. payItem(num) {
  350. if (this.userInfo.balance * 1 < this.orderRights.salePrice * 1) {
  351. return
  352. }
  353. this.curServiceTab = num
  354. },
  355. payRights(item) {
  356. this.userInfo = uni.getStorageSync('userInfo')
  357. if (!this.userInfo.phone) {
  358. uni.showModal({
  359. title: '温馨提示',
  360. content: '权益卡绑定信息需通过手机号进行获取,是否确认绑定手机号',
  361. success: res => {
  362. if (res.confirm) {
  363. uni.navigateTo({
  364. url: '/myPages/setting/setting-telphone',
  365. })
  366. }
  367. }
  368. })
  369. return
  370. }
  371. if (this.serviceObjectList[0].length === 0) {
  372. uni.showModal({
  373. title: '温馨提示',
  374. content: '默认服务对象不能使用权益卡,是否前往绑定新的服务对象?',
  375. success: res => {
  376. if (res.confirm) {
  377. uni.navigateTo({
  378. url: '/myPages/ServiceObjectManagement/index',
  379. })
  380. }
  381. }
  382. })
  383. return;
  384. }
  385. if (!this.selectIcon) {
  386. uni.$u.toast('请阅读并同意《娇骄儿权益服务协议》')
  387. return;
  388. }
  389. // this.show = true
  390. this.orderRights = item
  391. this.$refs.selectObjectPopup.open()
  392. }
  393. },
  394. };
  395. </script>
  396. <style lang="scss" scoped>
  397. @import '/common/css/common.css';
  398. @import './index.rpx.scss';
  399. </style>