index.vue 10.0 KB

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