couponDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <view class="creat">
  3. <!-- <view class="handle">
  4. <view class="head_left">
  5. <span class="cuIcon-back" @click="back"></span>
  6. </view>
  7. <span class="center">{{ currentTab == 0 ? '代金券详情' : currentTab == 1 ? '满减券详情' : '折扣券详情' }}</span>
  8. </view> -->
  9. <cu-custom bgColor="bg-fff" :isBack="true">
  10. <block slot="content">{{ currentTab == 0 ? '代金券详情' : currentTab == 1 ? '满减券详情' : '折扣券详情' }}</block>
  11. </cu-custom>
  12. <view class="top"></view>
  13. <!-- 代金券列表 -->
  14. <view class="content">
  15. <view class="coupon-card" style="padding-bottom: 2rpx;">
  16. <!-- 顶部标题栏 -->
  17. <view class="card-header"
  18. :style="currentTab == 0 ? 'background: #EFFFFE' : currentTab == 1 ? 'background: #F4FAFF ' : 'background: #FFF7F3'">
  19. <image style=" vertical-align: top"
  20. :src="`../../static/coupon/titlebg${Number(currentTab) +1}.png`" mode=""> </image>
  21. <view class="status" v-if="couponList.delFlag == '1'"
  22. :style="currentTab == 0 ? 'color: #2DAC9F' : currentTab == 1 ? 'color: #4183BC' : 'color: #DB6332'">
  23. 销售中
  24. </view>
  25. <view class="status" v-else>{{ couponList.delFlag == '0' ? '待上架' : couponList.delFlag == '2' ? '已失效'
  26. :
  27. '' }}</view>
  28. </view>
  29. <view class="flex" style="padding: 14rpx 18rpx;">
  30. <!-- 优惠券金额 -->
  31. <view class="amount-section">
  32. <text class="amount" v-if="currentTab == 0">{{ couponList.parValue }}</text>
  33. <text class="amount" v-else :style="currentTab == 1 ? 'color: #278BE5' : 'color: #FB5308'">{{
  34. couponList.contentInfo }}</text>
  35. <text class="unit" v-if="currentTab == 2">折</text>
  36. <text class="unit" v-else>元</text>
  37. <view class="use-condition" v-if="currentTab == 0 && couponList.voucherWay == '1'">售价{{
  38. couponList.voucherWayInfo
  39. }}元</view>
  40. <view class="use-condition" v-if="currentTab == 1 && couponList.contentConditions !== '0'">满{{
  41. couponList.contentConditions }}元可抵扣</view>
  42. <view class="use-condition" v-if="currentTab == 2 && couponList.contentConditions !== '0'">满{{
  43. couponList.contentConditions }}元可使用</view>
  44. <view class="use-condition" v-if="currentTab !== 0 && couponList.contentConditions == '0'">无条件使用
  45. </view>
  46. </view>
  47. <!-- 优惠券信息 -->
  48. <view class="info-section">
  49. <view class="info-item">
  50. <text class="dot">•</text>
  51. <text class="label" v-if="currentTab == 0">获取方式:</text>
  52. <text class="label" v-else>领取限制:</text>
  53. <text class="value" v-if="currentTab == 0">{{ couponList.voucherWay == '1' ? '购买' : '消费满' +
  54. couponList.voucherWayInfo + '元可领取' }}</text>
  55. <text class="value" v-else>{{ couponList.couponWay == '1' ? '所有人可领取' : '本店消费可领' }}</text>
  56. </view>
  57. <view class="info-item">
  58. <text class="dot">•</text>
  59. <text class="label" v-if="currentTab == 0">使用条件:</text>
  60. <text class="label" v-else>适用范围:</text>
  61. <text class="value" v-if="currentTab == 0">{{ couponList.conditions == '0' ? '不限制' : '最低消费'
  62. +
  63. couponList.conditions + '元' }}</text>
  64. <text class="value" v-else>{{
  65. couponList.couponRange == '1' ? '本店可用' : couponList.couponRange == '2'
  66. ? '部分分类商品可用' : '部分分类商品不可用' }}</text>
  67. </view>
  68. <view class="info-item">
  69. <text class="dot">•</text>
  70. <text class="label">有效期:</text>
  71. <text class="value">{{ couponList.beginTime + '/' + couponList.endTime }}</text>
  72. </view>
  73. </view>
  74. </view>
  75. <!-- 数量统计 -->
  76. <view class="stats-section flex"
  77. :class="currentTab == 0 ? 'backg-color1' : currentTab == 1 ? 'backg-color2' : 'backg-color3'">
  78. <text class="stat-item" v-if="currentTab == 0">已购买:{{ couponList.payNumber }}</text>
  79. <text class="stat-item" v-else>已领取:{{ couponList.receivedCount }}</text>
  80. <text class="stat-item">已使用:{{ couponList.useNumber }}</text>
  81. <text class="stat-item">总库存:{{ couponList.number }}</text>
  82. </view>
  83. </view>
  84. <view class="coupon-card" style="padding: 20rpx;">
  85. <view class="detail-title">详细信息</view>
  86. <view class="detail-group flex justify-between">
  87. <text class="label">{{ currentTab == 0 ? '代金券名称' : currentTab == 1 ? '满减券名称' : '折扣券名称' }}</text>
  88. <text class="value">{{ currentTab == 0 ? couponList.voucherName : couponList.couponName }}</text>
  89. </view>
  90. <view class="detail-group flex justify-between">
  91. <text class="label" v-if="currentTab == 0">获取方式</text>
  92. <text class="label" v-else>领取限制</text>
  93. <text class="value" v-if="currentTab == 0">{{ couponList.voucherWay == '1' ? '购买' : '消费满' +
  94. couponList.voucherWayInfo + '元可领取' }}</text>
  95. <text class="value" v-else>{{ couponList.couponWay == '1' ? '所有人可领取' : '本店消费可领' }}</text>
  96. </view>
  97. <view class="detail-group flex justify-between" v-if="currentTab == 0">
  98. <text class="label">使用条件</text>
  99. <text class="value">{{ couponList.conditions == '0' ? '不限制' : '最低消费' + couponList.conditions + '元'
  100. }}</text>
  101. </view>
  102. <view class="detail-group flex justify-between">
  103. <text class="label">适用范围</text>
  104. <text class="value" v-if="currentTab == 0 ">{{
  105. couponList.voucherRange == 1 ? '本店可用' : couponList.voucherRange == 2 ? '部分分类商品可用' :
  106. '部分分类商品不可用'
  107. }}</text>
  108. <text class="value" v-else>{{
  109. couponList.couponRange == 1 ? '本店可用' : couponList.couponRange == 2 ? '部分分类商品可用' :
  110. '部分分类商品不可用'
  111. }}</text>
  112. </view>
  113. <view class="detail-group flex justify-between">
  114. <text class="label">有效期</text>
  115. <text class="value">{{ couponList.beginTime + '/' + couponList.endTime }}</text>
  116. </view>
  117. <view class="detail-group flex justify-between">
  118. <text class="label">创建时间</text>
  119. <text class="value">{{ couponList.createTime }}</text>
  120. </view>
  121. <view class="detail-group flex justify-between" v-if="couponList.upperTime">
  122. <text class="label">上架时间</text>
  123. <text class="value">{{ couponList.upperTime }}</text>
  124. </view>
  125. </view>
  126. <view class="coupon-card" style="padding: 20rpx;"
  127. v-if="couponList.couponDescription !== null || couponList.couponPhoto !== null || couponList.voucherDescription !== null || couponList.voucherPhoto !== null">
  128. <text class="detail-title">{{ currentTab == 0 ? '代金券描述' : currentTab == 1 ? '满减券描述' : '折扣券描述' }}</text>
  129. <view class="detail-group ">
  130. <text class="value" v-if="currentTab == 0 ">{{ couponList.voucherDescription }}</text>
  131. <text class="value" v-else>{{ couponList.couponDescription }}</text>
  132. </view>
  133. <view v-for="val in couponList.couponPhoto" :key="val">
  134. <image :src="val" mode=""></image>
  135. </view>
  136. </view>
  137. </view>
  138. <view class="btn">
  139. <view class="delete" v-if="couponList.delFlag !== 1" @click="deleteFun">删除</view>
  140. <view class="submit" @click="submit">用户</view>
  141. </view>
  142. </view>
  143. </template>
  144. <script>
  145. export default {
  146. data() {
  147. return {
  148. currentTab: 0,
  149. activeItemStyle: {
  150. backgroundColor: 'rgba(41, 121, 255, 0.1)',
  151. borderRadius: '32rpx',
  152. transition: 'all 0.3s'
  153. },
  154. couponList: {},
  155. reductionList: [],
  156. discountList: [],
  157. productId: ''
  158. }
  159. },
  160. methods: {
  161. getForm() {
  162. let upDown = ['/merchant/localVoucherInfo/queryById', '/merchant/localCouponInfo/queryById', '/merchant/localCouponInfo/queryById']
  163. this.$http.get(upDown[this.currentTab], { params: { id: this.productId } }).then(res => {
  164. if (res.data.success) {
  165. if (this.currentTab == 0) {
  166. res.data.result.couponPhoto = res.data.result.voucherPhoto && res.data.result.voucherPhoto !== null ? res.data.result.voucherPhoto.split(',').filter(id => id) : []
  167. }
  168. else {
  169. res.data.result.couponPhoto = res.data.result.couponPhoto && res.data.result.couponPhoto !== null ? res.data.result.couponPhoto.split(',').filter(id => id) : []
  170. }
  171. this.couponList = res.data.result
  172. }
  173. else {
  174. this.$tip.error(res.data.message);
  175. }
  176. })
  177. },
  178. //返回
  179. back() {
  180. uni.navigateBack({
  181. delta: 1
  182. });
  183. },
  184. goCouponList() {
  185. const listTab = Number(this.currentTab) > 0 ? Number(this.currentTab) - 1 : 0
  186. setTimeout(() => {
  187. const pages = getCurrentPages()
  188. if (pages.length > 1) {
  189. uni.navigateBack()
  190. } else {
  191. uni.redirectTo({
  192. url: `/pages/coupon/coupon?tab=${listTab}`
  193. })
  194. }
  195. }, 500)
  196. },
  197. deleteFun() {
  198. uni.showModal({
  199. title: '删除优惠券',
  200. content: '当前优惠券确定删除?',
  201. success: (res) => {
  202. if (res.confirm) {
  203. if (this.currentTab == 0) {
  204. this.$http.get('/merchant/localVoucherInfo/delete?id=' + this.productId).then(res => {
  205. if (res.data.success) {
  206. uni.showToast({
  207. title: res.data.message || '删除成功',
  208. icon: 'none'
  209. })
  210. this.goCouponList()
  211. }
  212. else {
  213. this.$tip.error(res.data.message);
  214. }
  215. })
  216. }
  217. else {
  218. this.$http.delete(`/merchant/localCouponInfo/delete?id=${this.productId}&type=${this.currentTab}`).then(res => {
  219. if (res.data.success) {
  220. uni.showToast({
  221. title: res.data.message || '删除成功',
  222. icon: 'none'
  223. })
  224. this.goCouponList()
  225. }
  226. else {
  227. this.$tip.error(res.data.message);
  228. }
  229. })
  230. }
  231. }
  232. }
  233. })
  234. },
  235. submit() {
  236. let name=this.currentTab==0?this.couponList.voucherName:this.couponList.couponName
  237. uni.navigateTo({
  238. url: `/pages/coupon/usersList?id=${this.couponList.id}&tab=${this.currentTab}&name=${name}`
  239. })
  240. }
  241. },
  242. onLoad(options) {
  243. if (options) {
  244. this.productId = options.id
  245. this.currentTab = Number(options.tab) || 0
  246. }
  247. },
  248. onShow() {
  249. if (this.productId) {
  250. this.getForm()
  251. }
  252. }
  253. }
  254. </script>
  255. <style lang="scss" scoped>
  256. .coupon-card {
  257. // background: linear-gradient(to right, #ffffff, #f8fbff);
  258. background: #fff;
  259. border-radius: 12rpx;
  260. // padding: 30rpx;
  261. margin: 26rpx 32rpx;
  262. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
  263. .card-header {
  264. display: flex;
  265. justify-content: space-between;
  266. align-items: center;
  267. // margin-bottom: 20rpx;
  268. padding: 10rpx 18rpx;
  269. image {
  270. width: 230rpx;
  271. height: 50rpx;
  272. }
  273. .status {
  274. font-size: 26rpx;
  275. color: #999;
  276. }
  277. }
  278. .amount-section {
  279. width: 40%;
  280. text-align: center;
  281. .amount {
  282. font-size: 80rpx;
  283. font-weight: bold;
  284. color: #02C1AB
  285. }
  286. .unit {
  287. font-size: 22rpx;
  288. color: #999999;
  289. margin-left: 4rpx;
  290. }
  291. .use-condition {
  292. margin-top: 10rpx;
  293. font-size: 22rpx;
  294. color: #888888;
  295. }
  296. }
  297. .info-section {
  298. .info-item {
  299. display: flex;
  300. align-items: center;
  301. margin-bottom: 16rpx;
  302. font-size: 26rpx;
  303. color: #666;
  304. .dot {
  305. color: #999;
  306. margin-right: 8rpx;
  307. }
  308. .label {
  309. color: #999;
  310. }
  311. .value {
  312. color: #333;
  313. }
  314. }
  315. }
  316. .backg-color1 {
  317. color: #2BC0AE;
  318. background: linear-gradient(90deg, #EFFFFE 0%, #F8FFFF 100%);
  319. }
  320. .backg-color2 {
  321. color: #5399D6;
  322. background: linear-gradient(90deg, #F4FAFF 0%, #FAFDFF 100%);
  323. }
  324. .backg-color3 {
  325. color: #E97C4F;
  326. background: linear-gradient(90deg, #FFF7F3 0%, #FFFBF8 100%);
  327. }
  328. .stats-section {
  329. display: flex;
  330. margin: 0 16rpx 13rpx 16rpx;
  331. padding: 13rpx 0;
  332. font-size: 24rpx;
  333. .stat-item {
  334. // margin-right: 40rpx;
  335. width: 33.33%;
  336. border-right: 1px solid #D4ECEA;
  337. text-align: center;
  338. &:last-child {
  339. margin-right: 0;
  340. }
  341. }
  342. .stat-item:last-child {
  343. border-right: none;
  344. }
  345. }
  346. }
  347. .handle {
  348. height: 112rpx;
  349. display: flex;
  350. justify-content: space-between;
  351. align-items: center;
  352. padding: 0px 24rpx;
  353. position: relative;
  354. background: #fff;
  355. // background: linear-gradient(90deg, #D8EAFF 4%, #E6F8F8 67%, #DDF1FA 100%), linear-gradient(#FFFFFF 0%, rgba(247, 248, 252, 0) 100%);
  356. .head_left {
  357. font-size: 40rpx;
  358. }
  359. .center {
  360. position: absolute;
  361. left: 50%;
  362. top: 50%;
  363. transform: translate(-50%, -50%);
  364. font-size: 36rpx;
  365. font-weight: 600;
  366. }
  367. .head_right {
  368. display: flex;
  369. justify-content: space-between;
  370. align-items: center;
  371. span {
  372. width: 40rpx;
  373. height: 40rpx;
  374. display: flex;
  375. justify-content: center;
  376. align-items: center;
  377. }
  378. .manage {
  379. // width: 150rpx;
  380. margin-left: 28rpx;
  381. }
  382. }
  383. }
  384. .detail-title {
  385. font-weight: 500;
  386. font-size: 34rpx;
  387. color: #333333;
  388. }
  389. .detail-group {
  390. margin-top: 22rpx;
  391. .label {
  392. color: #666666;
  393. font-size: 28rpx;
  394. }
  395. .value {
  396. font-size: 30rpx;
  397. color: #333333;
  398. }
  399. }
  400. .btn {
  401. width: 100%;
  402. height: 112rpx;
  403. background-color: #fff;
  404. display: flex;
  405. justify-content: space-evenly;
  406. align-items: center;
  407. padding: 16rpx 24rpx;
  408. .delete {
  409. width: 45%;
  410. height: 76rpx;
  411. border: 1px solid #CCCCCC;
  412. border-radius: 75rpx;
  413. display: flex;
  414. align-items: center;
  415. justify-content: center;
  416. font-size: 28rpx;
  417. color: #999999;
  418. }
  419. .submit {
  420. width: 45%;
  421. height: 76rpx;
  422. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  423. border-radius: 75rpx;
  424. display: flex;
  425. align-items: center;
  426. justify-content: center;
  427. font-size: 28rpx;
  428. color: #FFFFFF;
  429. }
  430. }
  431. .creat {
  432. width: 100vw;
  433. height: 100vh;
  434. background: #F7F8FC;
  435. display: flex;
  436. flex-direction: column;
  437. justify-content: space-between;
  438. /*#ifdef APP-PLUS*/
  439. .top {
  440. width: 100%;
  441. height: var(--status-bar-height);
  442. background-color: #fff;
  443. }
  444. /* #endif */
  445. }
  446. .content {
  447. width: 100%;
  448. flex: 1;
  449. overflow-y: auto;
  450. }
  451. </style>