index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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>
  19. <view class="h-center-content flex-col justify-around ">
  20. <view class="h-value">
  21. <text>{{item.title}}</text>
  22. </view>
  23. <view class="title">
  24. 适用项目:{{item.serviceProjectName || ''}}
  25. </view>
  26. <view class="title">
  27. 适用门店:{{ item.useStoreDesc || '' }}
  28. </view>
  29. <view class="title">
  30. 绑定对象:{{item.serviceObjectName}}
  31. </view>
  32. <view class="title">
  33. 结束期限:{{item.effectiveEndTime.substring(0,10)}}
  34. </view>
  35. </view>
  36. <view class=" flex-col justify-center ">
  37. <image class="h-right-content-img " :src="item.facePhotoUrl || '/static/logo.png'" mode="aspectFit" @click="magnify(item.facePhotoUrl)"></image>
  38. </view>
  39. </view>
  40. <view class="actionBar flex-row justify-end" >
  41. <view class="actionBtn renewBtn" v-if="item.isShow" @click.stop="navigateTo(item)">续费</view>
  42. <view class="actionBtn upgradeBtn" @click.stop="upgrade(item)">升级</view>
  43. </view>
  44. <view v-if="showRemarkId == item.id" class="remark" style="text-indent:unset">
  45. <view v-if="item.unavailableWeeklyTimes || item.unavailableTimeRanges">
  46. 不可用日期:
  47. <view v-if="item.unavailableWeeklyTimes">{{ parseWeeklyTimes(item.unavailableWeeklyTimes) }}</view>
  48. <view v-if="item.unavailableTimeRanges">{{ parseTimeRanges(item.unavailableTimeRanges) }}</view>
  49. </view>
  50. <view v-if="item.delayEffectiveDays > 0">
  51. 生效时间:
  52. <text>购买后{{item.delayEffectiveDays}}天生效</text>
  53. </view>
  54. <view v-if="item.description !=null">
  55. 使用说明:
  56. <text>{{ item.description }}</text>
  57. </view>
  58. <text v-else class="remarkText">该优惠券暂无使用说明</text>
  59. </view>
  60. </view>
  61. </scroll-view>
  62. <uni-popup ref="popup">
  63. <view class="magnifyUrlView">
  64. <image :src="magnifyUrl" mode="widthFix"></image>
  65. </view>
  66. </uni-popup>
  67. <uni-popup ref="upgradePopup" type="center">
  68. <view class="upgradePopupView">
  69. <view class="upgradeTitle">请选择升级活动</view>
  70. <scroll-view class="upgradeScroll" scroll-y>
  71. <view class="upgradeItem" v-for="(act,idx) in upgradeActivityList" :key="idx" @click="selectUpgradeActivity(idx)">
  72. <view class="upgradeItemTitle">{{act.title}}</view>
  73. <view class="upgradeItemPrice">活动价格:<text class="upgradePrice">{{act.salePrice}}元</text></view>
  74. </view>
  75. </scroll-view>
  76. <view class="upgradeCloseBtn" @click="closeUpgradePopup">取消</view>
  77. </view>
  78. </uni-popup>
  79. </view>
  80. </template>
  81. <script>
  82. import {date} from "@/uni_modules/uv-ui-tools/libs/function/test";
  83. export default {
  84. data() {
  85. return {
  86. showRemarkId:'',
  87. magnifyUrl:'',
  88. windowHeight:'',
  89. userInfo:{},
  90. equityList:[],
  91. upgradeActivityList:[],
  92. currentUpgradeItem:null,
  93. };
  94. },
  95. computed: {
  96. // 解析 unavailableWeeklyTimes,将 "3,4,5" 转换为 ["星期二", "星期三", "星期四"]
  97. parseWeeklyTimes() {
  98. return function(times) {
  99. if (!times) return '';
  100. const arr = times.split(',');
  101. const weekMap = {
  102. '1': '星期日',
  103. '2': '星期一',
  104. '3': '星期二',
  105. '4': '星期三',
  106. '5': '星期四',
  107. '6': '星期五',
  108. '7': '星期六'
  109. };
  110. return arr.map(item => weekMap[item]).join('、');
  111. };
  112. },
  113. // 解析 unavailableTimeRanges,将 JSON 字符串转换为可读格式
  114. parseTimeRanges() {
  115. return function(ranges) {
  116. if (!ranges) return '';
  117. try {
  118. const arr = JSON.parse(ranges);
  119. return arr.map(item => {
  120. const begin = item.beginTime?.split?.(' ')?.[0] || '';
  121. const end = item.endTime?.split?.(' ')?.[0] || '';
  122. return begin && end ? `${begin} - ${end}` : '';
  123. }).filter(Boolean).join(';');
  124. } catch (e) {
  125. return '';
  126. }
  127. };
  128. }
  129. },
  130. onLoad(option) {
  131. let sysInfo = uni.getSystemInfoSync()
  132. this.windowHeight =sysInfo.windowHeight - 3 +'px'//除标题栏栏外的屏幕可用高度
  133. this.userInfo = uni.getStorageSync('userInfo')
  134. this.myEquityCardList()
  135. },
  136. methods: {
  137. isShow(item){
  138. if (item.effectiveEndTime){
  139. let date = new Date(item.effectiveEndTime);
  140. let now = new Date().getTime();
  141. const timeDiff = Math.abs(now - date.getTime());
  142. const ninetyDaysMs = 90 * 24 * 60 * 60 * 1000;
  143. return timeDiff < ninetyDaysMs;
  144. }
  145. return false
  146. },
  147. navigateTo(item){
  148. console.log('+++++++++++++++++++++++++++++++',item)
  149. if(item.activityId){
  150. let list = item.activityId.split(',')
  151. if (list.length == 1){
  152. uni.navigateTo({
  153. url:'/orderPages/activityDetail/activityDetail?id=' + item.activityId +'&renewServiceObjectId=' + item.serviceObjectId
  154. })
  155. }else {
  156. uni.navigateTo({
  157. url:'/orderPages/activityList/activityList?renewServiceObjectId=' + item.serviceObjectId + '&equityCardId=' + item.equityCardId
  158. })
  159. }
  160. }else{
  161. uni.navigateTo({
  162. url:'/orderPages/activityList/activityList?renewServiceObjectId=' + item.serviceObjectId
  163. })
  164. }
  165. },
  166. upgrade(item){
  167. if (!item.equityCardId){
  168. uni.showToast({
  169. title: '当前权益卡暂无可升级活动',
  170. icon: 'none'
  171. })
  172. return
  173. }
  174. uni.showLoading({title: '加载中'})
  175. this.$api.upgradeList(item.equityCardId).then(res=>{
  176. uni.hideLoading()
  177. const list = (res && res.data && (res.data.data || res.data.rows)) || []
  178. if (!list || list.length === 0){
  179. uni.showToast({
  180. title: '当前权益卡暂无可升级活动',
  181. icon: 'none'
  182. })
  183. return
  184. }
  185. this.currentUpgradeItem = item
  186. if (list.length === 1){
  187. this.goUpgradeDetail(list[0], item)
  188. }else {
  189. this.upgradeActivityList = list
  190. this.$refs.upgradePopup.open()
  191. }
  192. }).catch(()=>{
  193. uni.hideLoading()
  194. })
  195. },
  196. selectUpgradeActivity(idx){
  197. const activity = this.upgradeActivityList[idx]
  198. console.log(activity, 'activity')
  199. this.goUpgradeDetail(activity, this.currentUpgradeItem)
  200. this.closeUpgradePopup()
  201. },
  202. goUpgradeDetail(activity, item){
  203. console.log(activity, item,'activity, item')
  204. if (!activity || !activity.id){
  205. return
  206. }
  207. let url = '/orderPages/activityDetail/activityDetail?id=' + activity.id + '&upgradeEquityCardId=' + item.id
  208. if (item.serviceObjectId){
  209. url += '&renewServiceObjectId=' + item.serviceObjectId
  210. }
  211. uni.navigateTo({url})
  212. },
  213. closeUpgradePopup(){
  214. this.$refs.upgradePopup.close()
  215. },
  216. showRemark(item) {
  217. if (this.showRemarkId == item.id) {
  218. this.showRemarkId = ''
  219. } else {
  220. this.showRemarkId = item.id
  221. }
  222. },
  223. magnify(url){
  224. if (!url){
  225. return
  226. }
  227. this.magnifyUrl = url
  228. this.$refs.popup.open()
  229. },
  230. myEquityCardList(){
  231. this.$api.myEquityCardList().then(res=>{
  232. console.log(res)
  233. this.equityList = res.data.data
  234. for (let equityListElement of this.equityList) {
  235. let a = this.isShow(equityListElement)
  236. console.log(a)
  237. equityListElement.isShow = this.isShow(equityListElement)
  238. }
  239. if (this.equityList){
  240. this.getImgUrlByBannerOssId(this.equityList)
  241. }
  242. })
  243. },
  244. // 获取图片
  245. getImgUrlByBannerOssId(items){
  246. for(let i = 0; i <items.length; i++) {
  247. if (items[i].facePhoto){
  248. this.$api.getImgUrlByOssId({ossId:items[i].facePhoto}).then(res=>{
  249. console.log('++++++++++++facePhotoUrl+++++++++',res.data.data[0].url.replace(/^http:/, "https:"))
  250. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  251. this.$set(this.equityList,i,items[i])
  252. })
  253. }
  254. }
  255. },
  256. },
  257. };
  258. </script>
  259. <style lang="scss" scoped>
  260. @import '/common/css/common.css';
  261. @import './index.rpx.scss';
  262. </style>