index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view class="page" :style="{'height':windowHeight}">
  3. <view class="flex-col" v-if="!equityList">
  4. <view class="flex-row justify-center">
  5. <image class="empty" src="/static/imageIcon/empty.png" mode="widthFix"></image>
  6. </view>
  7. <view class="emptyText flex-row justify-center">
  8. <text>暂无内容</text>
  9. </view>
  10. </view>
  11. <scroll-view v-else scroll-y :style="{'height':windowHeight}">
  12. <view class="row-list" v-for="(item,index) in equityList" :key="index">
  13. <view class="flex-row justify-start" @click.stop="showRemark(item)">
  14. <view class="h-text flex-col justify-center ">
  15. <view class="money">
  16. <text>{{item.faceValue}}</text>
  17. </view>
  18. <!-- <view class="desc">-->
  19. <!-- <text>{{item.title}}</text>-->
  20. <!-- </view>-->
  21. <view class="flex-row justify-center" v-if="item.isShow">
  22. <text style="font-size: 28rpx;font-weight: bold;color: red;" @click.stop="navigateTo(item)">点击续费</text>
  23. </view>
  24. </view>
  25. <view class="h-center-content flex-col justify-around ">
  26. <view class="h-value">
  27. <text>{{item.title}}</text>
  28. </view>
  29. <view class="title">
  30. 适用项目:{{item.serviceProjectName || ''}}
  31. </view>
  32. <view class="title">
  33. 适用门店:{{ item.useStoreDesc || '' }}
  34. </view>
  35. <view class="title">
  36. 绑定对象:{{item.serviceObjectName}}
  37. </view>
  38. <view class="title">
  39. 结束期限:{{item.effectiveEndTime.substring(0,10)}}
  40. </view>
  41. </view>
  42. <view class=" flex-col justify-center ">
  43. <image class="h-right-content-img " :src="item.facePhotoUrl || '/static/logo.png'" mode="aspectFit" @click="magnify(item.facePhotoUrl)"></image>
  44. </view>
  45. </view>
  46. <view v-if="showRemarkId == item.id" class="remark" style="text-indent:unset">
  47. <view v-if="item.unavailableWeeklyTimes || item.unavailableTimeRanges">
  48. 不可用日期:
  49. <view v-if="item.unavailableWeeklyTimes">{{ parseWeeklyTimes(item.unavailableWeeklyTimes) }}</view>
  50. <view v-if="item.unavailableTimeRanges">{{ parseTimeRanges(item.unavailableTimeRanges) }}</view>
  51. </view>
  52. <view v-if="item.delayEffectiveDays > 0">
  53. 生效时间:
  54. <text>购买后{{item.delayEffectiveDays}}天生效</text>
  55. </view>
  56. <view v-if="item.description !=null">
  57. 使用说明:
  58. <text>{{ item.description }}</text>
  59. </view>
  60. <text v-else class="remarkText">该优惠券暂无使用说明</text>
  61. </view>
  62. </view>
  63. </scroll-view>
  64. <uni-popup ref="popup">
  65. <view class="magnifyUrlView">
  66. <image :src="magnifyUrl" mode="widthFix"></image>
  67. </view>
  68. </uni-popup>
  69. </view>
  70. </template>
  71. <script>
  72. import {date} from "@/uni_modules/uv-ui-tools/libs/function/test";
  73. export default {
  74. data() {
  75. return {
  76. showRemarkId:'',
  77. magnifyUrl:'',
  78. windowHeight:'',
  79. userInfo:{},
  80. equityList:[],
  81. };
  82. },
  83. computed: {
  84. // 解析 unavailableWeeklyTimes,将 "3,4,5" 转换为 ["星期二", "星期三", "星期四"]
  85. parseWeeklyTimes() {
  86. return function(times) {
  87. if (!times) return '';
  88. const arr = times.split(',');
  89. const weekMap = {
  90. '1': '星期日',
  91. '2': '星期一',
  92. '3': '星期二',
  93. '4': '星期三',
  94. '5': '星期四',
  95. '6': '星期五',
  96. '7': '星期六'
  97. };
  98. return arr.map(item => weekMap[item]).join('、');
  99. };
  100. },
  101. // 解析 unavailableTimeRanges,将 JSON 字符串转换为可读格式
  102. parseTimeRanges() {
  103. return function(ranges) {
  104. if (!ranges) return '';
  105. try {
  106. const arr = JSON.parse(ranges);
  107. return arr.map(item => {
  108. const begin = item.beginTime?.split?.(' ')?.[0] || '';
  109. const end = item.endTime?.split?.(' ')?.[0] || '';
  110. return begin && end ? `${begin} - ${end}` : '';
  111. }).filter(Boolean).join(';');
  112. } catch (e) {
  113. return '';
  114. }
  115. };
  116. }
  117. },
  118. onLoad(option) {
  119. let sysInfo = uni.getSystemInfoSync()
  120. this.windowHeight =sysInfo.windowHeight - 3 +'px'//除标题栏栏外的屏幕可用高度
  121. this.userInfo = uni.getStorageSync('userInfo')
  122. this.myEquityCardList()
  123. },
  124. methods: {
  125. isShow(item){
  126. if (item.effectiveEndTime){
  127. let date = new Date(item.effectiveEndTime);
  128. let now = new Date().getTime();
  129. const timeDiff = Math.abs(now - date.getTime());
  130. const ninetyDaysMs = 90 * 24 * 60 * 60 * 1000;
  131. return timeDiff < ninetyDaysMs;
  132. }
  133. return false
  134. },
  135. navigateTo(item){
  136. console.log('+++++++++++++++++++++++++++++++',item)
  137. if(item.activityId){
  138. let list = item.activityId.split(',')
  139. if (list.length == 1){
  140. uni.navigateTo({
  141. url:'/orderPages/activityDetail/activityDetail?id=' + item.activityId +'&renewServiceObjectId=' + item.serviceObjectId
  142. })
  143. }else {
  144. uni.navigateTo({
  145. url:'/orderPages/activityList/activityList?renewServiceObjectId=' + item.serviceObjectId + '&equityCardId=' + item.equityCardId
  146. })
  147. }
  148. }else{
  149. uni.navigateTo({
  150. url:'/orderPages/activityList/activityList?renewServiceObjectId=' + item.serviceObjectId
  151. })
  152. }
  153. },
  154. showRemark(item) {
  155. if (this.showRemarkId == item.id) {
  156. this.showRemarkId = ''
  157. } else {
  158. this.showRemarkId = item.id
  159. }
  160. },
  161. magnify(url){
  162. if (!url){
  163. return
  164. }
  165. this.magnifyUrl = url
  166. this.$refs.popup.open()
  167. },
  168. myEquityCardList(){
  169. this.$api.myEquityCardList().then(res=>{
  170. console.log(res)
  171. this.equityList = res.data.data
  172. for (let equityListElement of this.equityList) {
  173. let a = this.isShow(equityListElement)
  174. console.log(a)
  175. equityListElement.isShow = this.isShow(equityListElement)
  176. }
  177. if (this.equityList){
  178. this.getImgUrlByBannerOssId(this.equityList)
  179. }
  180. })
  181. },
  182. // 获取图片
  183. getImgUrlByBannerOssId(items){
  184. for(let i = 0; i <items.length; i++) {
  185. if (items[i].facePhoto){
  186. this.$api.getImgUrlByOssId({ossId:items[i].facePhoto}).then(res=>{
  187. console.log('++++++++++++facePhotoUrl+++++++++',res.data.data[0].url.replace(/^http:/, "https:"))
  188. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  189. this.$set(this.equityList,i,items[i])
  190. })
  191. }
  192. }
  193. },
  194. },
  195. };
  196. </script>
  197. <style lang="scss" scoped>
  198. @import '/common/css/common.css';
  199. @import './index.rpx.scss';
  200. </style>