detail.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <view v-if="!isLoading" class="container b-f p-b">
  3. <view class="base">
  4. <view class="coupon-main">
  5. <view class="left">
  6. <image class="image" :src="detail.image"></image>
  7. </view>
  8. <view class="right">
  9. <view class="item">
  10. <view class="name">{{ detail.name ? detail.name : '' }}</view>
  11. </view>
  12. <view v-if="detail.type == 'P'" class="item">
  13. <view class="amount"><text class="num">{{ detail.balance }}</text></view>
  14. </view>
  15. </view>
  16. </view>
  17. <view v-if="detail.amount > 0" class="item">
  18. <view class="label">卡券面额:</view>
  19. <view class="amount">{{ detail.amount }}</view>
  20. </view>
  21. <view class="item">
  22. <view class="label">有效期至:</view>
  23. <view>{{ detail.effectiveDate }}</view>
  24. </view>
  25. <view v-if="detail.code && detail.status == 'A' && detail.isGive" class="gift" @click="give()"><text>转赠好友</text></view>
  26. </view>
  27. <view class="coupon-qr">
  28. <view>
  29. <image class="image" :src="detail.qrCode"></image>
  30. </view>
  31. <view class="qr-code">
  32. <p class="code">卡号:{{ detail.code }}</p>
  33. <p class="tips">请出示以上卡号给核销人员</p>
  34. </view>
  35. </view>
  36. <view class="coupon-content m-top20">
  37. <view class="title">使用须知</view>
  38. <view class="content"><jyf-parser :html="detail.description ? detail.description : '暂无...'"></jyf-parser></view>
  39. </view>
  40. <!-- 底部选项卡 -->
  41. <view class="footer-fixed">
  42. <view class="footer-container">
  43. <view class="foo-item-btn">
  44. <view class="btn-wrapper">
  45. <view v-if="detail.status != 'D'" class="btn-item btn-item-main" @click="remove(userCouponId)">
  46. <text>删除卡券</text>
  47. </view>
  48. <view v-if="detail.status == 'D'" class="btn-item btn-item-main state">
  49. <text>已删除</text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <!-- 快捷导航 -->
  56. <shortcut />
  57. <view class="give-popup">
  58. <uni-popup ref="givePopup" type="dialog">
  59. <uni-popup-dialog mode="input" title="转赠给好友" type="info" placeholder="输入好友手机号码" :before-close="true" @close="cancelGive" @confirm="doGive"></uni-popup-dialog>
  60. </uni-popup>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import jyfParser from '@/components/jyf-parser/jyf-parser'
  66. import Shortcut from '@/components/shortcut'
  67. import * as myCouponApi from '@/api/myCoupon'
  68. import * as giveApi from '@/api/give'
  69. export default {
  70. components: {
  71. Shortcut
  72. },
  73. data() {
  74. return {
  75. // 卡券ID
  76. couponId: null,
  77. // 加载中
  78. isLoading: true,
  79. // 卡券详情
  80. detail: null,
  81. qrCode: ""
  82. }
  83. },
  84. /**
  85. * 生命周期函数--监听页面加载
  86. */
  87. onLoad(options) {
  88. // 记录ID
  89. this.userCouponId = options.userCouponId
  90. // 获取卡券详情
  91. this.getCouponDetail()
  92. },
  93. methods: {
  94. // 获取卡券详情
  95. getCouponDetail() {
  96. const app = this
  97. myCouponApi.detail(0, app.userCouponId, "")
  98. .then(result => {
  99. app.detail = result.data
  100. })
  101. .finally(() => app.isLoading = false)
  102. },
  103. // 转赠
  104. give() {
  105. this.$refs.givePopup.open('top')
  106. },
  107. // 取消转赠
  108. cancelGive() {
  109. this.$refs.givePopup.close()
  110. },
  111. // 确定转赠
  112. doGive(friendMobile) {
  113. const app = this
  114. if (friendMobile.length < 11) {
  115. app.$error("请先输入好友手机号码!")
  116. return false
  117. } else {
  118. app.$refs.givePopup.close()
  119. const param = {'mobile': friendMobile,
  120. 'couponId': this.userCouponId,
  121. 'message': '转赠一张优惠券给你'}
  122. giveApi.doGive(param)
  123. .then(result => {
  124. if (result.code == '200') {
  125. uni.showModal({
  126. title: '提示信息',
  127. content: '恭喜,转增成功!',
  128. showCancel: false,
  129. success(o) {
  130. if (o.confirm) {
  131. uni.navigateBack()
  132. }
  133. }
  134. })
  135. } else {
  136. app.$error(result.message)
  137. }
  138. })
  139. }
  140. },
  141. // 删除卡券
  142. remove() {
  143. const app = this;
  144. if (app.isLoading == true) {
  145. return false;
  146. }
  147. uni.showModal({
  148. title: "提示",
  149. content: "您确定要删除吗?",
  150. success({ confirm }) {
  151. if (confirm) {
  152. app.isLoading = true;
  153. myCouponApi.remove(app.userCouponId)
  154. .then(result => {
  155. app.getCouponDetail();
  156. app.isLoading = false;
  157. })
  158. .finally(() => app.isLoading = false)
  159. }
  160. }
  161. });
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. .container {
  168. min-height: 100vh;
  169. padding: 20rpx;
  170. background: #fff;
  171. }
  172. .base {
  173. border: dashed 5rpx #cccccc;
  174. padding: 15rpx 0rpx 15rpx 15rpx;
  175. border-radius: 10rpx;
  176. margin: 20rpx;
  177. height: auto;
  178. min-height: 420rpx;
  179. .coupon-main {
  180. clear: both;
  181. min-height: 164rpx;
  182. border: #ccc dashed 2rpx;
  183. border-radius: 5rpx;
  184. margin-bottom: 20rpx;
  185. .left {
  186. width: 215rpx;
  187. float: left;
  188. .image {
  189. width: 210rpx;
  190. height: 160rpx;
  191. border-radius: 8rpx;
  192. border-right: #cccccc dashed 2rpx;
  193. }
  194. }
  195. .right {
  196. width: 380rpx;
  197. float: left;
  198. overflow: hidden;
  199. .name {
  200. font-size: 38rpx;
  201. margin-left: 6rpx;
  202. }
  203. .num {
  204. font-size: 58rpx;
  205. color: red;
  206. }
  207. }
  208. }
  209. .item {
  210. clear: both;
  211. margin-bottom: 10rpx;
  212. font-size: 30rpx;
  213. color: #666666;
  214. .label {
  215. float: left;
  216. }
  217. .amount {
  218. font-weight: bold;
  219. }
  220. .name {
  221. font-weight: bold;
  222. }
  223. }
  224. }
  225. .coupon-qr {
  226. border: dashed 5rpx #cccccc;
  227. border-radius: 10rpx;
  228. margin: 20rpx;
  229. text-align: center;
  230. padding: 30rpx 15rpx 30rpx 15rpx;
  231. .image{
  232. width: 360rpx;
  233. height: 360rpx;
  234. margin: 0 auto;
  235. }
  236. .qr-code{
  237. .code{
  238. font-weight: bold;
  239. font-size: 30rpx;
  240. line-height: 50rpx;
  241. }
  242. .tips{
  243. font-size: 25rpx;
  244. color:#C0C4CC;
  245. }
  246. }
  247. }
  248. .coupon-content {
  249. font-size: 28rpx;
  250. padding: 30rpx;
  251. border: dashed 5rpx #cccccc;
  252. border-radius: 5rpx;
  253. margin: 20rpx 20rpx 200rpx 20rpx;
  254. min-height: 400rpx;
  255. .title {
  256. margin-bottom: 15rpx;
  257. }
  258. }
  259. .gift {
  260. height: 46rpx;
  261. width: 120rpx;
  262. margin-top: 20rpx;
  263. line-height: 46rpx;
  264. text-align: center;
  265. border: 1px solid #f8df00;
  266. border-radius: 6rpx;
  267. color: #f86d48;
  268. background: #f8df98;
  269. font-size: 22rpx;
  270. float: right;
  271. &.state {
  272. border: none;
  273. color: #cccccc;
  274. background: #F5F5F5;
  275. }
  276. }
  277. /* 底部操作栏 */
  278. .footer-fixed {
  279. position: fixed;
  280. bottom: var(--window-bottom);
  281. left: 0;
  282. right: 0;
  283. display: flex;
  284. height: 180rpx;
  285. padding-bottom: 30rpx;
  286. z-index: 11;
  287. box-shadow: 0 -4rpx 40rpx 0 rgba(144, 52, 52, 0.1);
  288. background: #fff;
  289. }
  290. .footer-container {
  291. width: 100%;
  292. display: flex;
  293. }
  294. // 操作按钮
  295. .foo-item-btn {
  296. flex: 1;
  297. .btn-wrapper {
  298. height: 100%;
  299. display: flex;
  300. align-items: center;
  301. }
  302. .btn-item {
  303. flex: 1;
  304. font-size: 28rpx;
  305. height: 80rpx;
  306. line-height: 80rpx;
  307. margin-right: 16rpx;
  308. margin-left: 16rpx;
  309. text-align: center;
  310. color: #fff;
  311. border-radius: 80rpx;
  312. }
  313. // 领取按钮
  314. .btn-item-main {
  315. background: linear-gradient(to right, #f9211c, #ff6335);
  316. &.state {
  317. border: none;
  318. color: #cccccc;
  319. background: #F5F5F5;
  320. }
  321. }
  322. }
  323. </style>