coupon-item-info.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <view class="special-item-info-page">
  3. <scroll-view scroll-y class="scroll-content">
  4. <view class="cell-wrap">
  5. <view class="item">
  6. <view class="label">活动状态</view>
  7. <view class="value between">
  8. <view class="curr-status" :class="{ ing: form.status === 1 }">{{ form.status === 1 ? '进行中' : '停止' }}</view>
  9. <view class="update-status" @click="handUpdateStatus">修改状态</view>
  10. </view>
  11. </view>
  12. <view class="item">
  13. <view class="label">优惠券标题</view>
  14. <view class="value">
  15. {{form.couponName}}
  16. </view>
  17. </view>
  18. <view class="item">
  19. <view class="label">子标题</view>
  20. <view class="value">
  21. {{form.couponTitle}}
  22. </view>
  23. </view>
  24. <view class="item">
  25. <view class="label">优惠券图片</view>
  26. <view class="value">
  27. <view class="cover">
  28. <image class="img" :src="item.pictureUrl"/>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="item">
  33. <view class="label">优惠类型</view>
  34. <view class="value">
  35. <uni-data-select
  36. v-model="form.discountType"
  37. :localdata="discountTypeList"
  38. @change="changeDiscountType"
  39. :border="false"
  40. :clear="false"
  41. :disabled="true"
  42. ></uni-data-select>
  43. </view>
  44. </view>
  45. <view class="item" v-if="form.discountType === 1">
  46. <view class="label">满减标准金额</view>
  47. <view class="value">
  48. {{form.couponFullPrice}}
  49. </view>
  50. </view>
  51. <view class="item" v-if="form.discountType !== 3 && form.discountType !== 4">
  52. <view class="label">面额</view>
  53. <view class="value">
  54. {{form.price}}
  55. </view>
  56. </view>
  57. <view class="item" v-if="form.discountType === 3">
  58. <view class="label">折扣(%)</view>
  59. <view class="value">
  60. {{form.couponDiscount}}
  61. </view>
  62. </view>
  63. <view class="item">
  64. <view class="label">可领取人群</view>
  65. <view class="value">
  66. <uni-data-select
  67. v-model="form.useScopeMember"
  68. :localdata="useScopeMemberList"
  69. @change="changeUseScopeMember"
  70. :border="false"
  71. :clear="false"
  72. :disabled="true"
  73. ></uni-data-select>
  74. </view>
  75. </view>
  76. <view class="item">
  77. <view class="label">活动时间</view>
  78. <view class="value">
  79. {{ form.startDate|formatDate('MM.dd') }} ~ {{ form.endDate|formatDate('MM.dd') }}
  80. </view>
  81. </view>
  82. <view class="item">
  83. <view class="label">优惠券状态</view>
  84. <view class="value">
  85. {{form.status}}
  86. </view>
  87. </view>
  88. <view class="item">
  89. <view class="label">发行数量</view>
  90. <view class="value">
  91. {{form.publishNum}}
  92. </view>
  93. </view>
  94. <view class="item">
  95. <view class="label">说明</view>
  96. <view class="value">
  97. {{form.remark || ''}}
  98. </view>
  99. </view>
  100. <view class="goods-wrap" v-if="form.discountType === 4">
  101. <view class="title">参与的商品(不支持多规格商品)</view>
  102. <view class="goods" v-for="item in goodsList" :key="item.goodsId">
  103. <view class="cover">
  104. <image class="img" :src="item.pictureUrl"/>
  105. </view>
  106. <view class="cont">
  107. <view class="name">{{item.goodsName}}</view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </scroll-view>
  113. <view class="update-events">
  114. <view class="btn" @click="deleteActivity">删除</view>
  115. <view class="btn" @click="updateCouponItem">调整优惠券</view>
  116. </view>
  117. </view>
  118. </template>
  119. <script>
  120. import {mapState} from 'vuex';
  121. export default {
  122. data () {
  123. return {
  124. getStoreCouponByIdUrl: '/coupon/getStoreCouponByIdForStore',
  125. updateStoreCouponStatusUrl: '/coupon/changeCouponStatusForStore',
  126. deleteStoreCouponUrl: '/coupon/deleteCouponByIdForStore',
  127. form: {
  128. couponId: '',
  129. couponName: '',
  130. couponTitle: '',
  131. discountType: '',
  132. couponType: 2,
  133. couponDiscount: '',
  134. couponFullPrice: '',
  135. imgUrl: '',
  136. storeId: '',
  137. goodsId: '',
  138. useScopeMember: '',
  139. startDate: '',
  140. endDate: '',
  141. status: 0,
  142. price: '',
  143. publishNum: '',
  144. receivedNum: '',
  145. usedNum: '',
  146. remark: '',
  147. goodsName: '',
  148. pictureUrl: ''
  149. },
  150. goodsList: [],
  151. discountTypeList: [
  152. { value: 1, text: "满减券" },
  153. { value: 2, text: "抵扣券" },
  154. { value: 3, text: "折扣券" },
  155. { value: 4, text: "兑换券" },
  156. ],
  157. useScopeMemberList: [
  158. {value: 1, text: '周期内限领'},
  159. {value: 2, text: '注册周期内累计消费'},
  160. {value: 3, text: '注册周期'},
  161. {value: 4, text: '新用户'}
  162. ],
  163. }
  164. },
  165. computed: {
  166. ...mapState(['storeInfo'])
  167. },
  168. methods: {
  169. loadData() {
  170. uni.showLoading({
  171. title: '加载中'
  172. });
  173. var dateStr = (new Date()).getTime();
  174. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  175. this.requst({
  176. url: this.getStoreCouponByIdUrl,
  177. data: {
  178. timestamp: dateStr,
  179. sign: sign,
  180. storeId: this.storeInfo.storeId,
  181. id: this.form.couponId
  182. },
  183. success: res => {
  184. this.goodsList = []
  185. this.form = res.data.obj;
  186. if (this.form.goodsId) {
  187. let goods = {
  188. goodsId: this.form.goodsId,
  189. goodsName: this.form.goodsName,
  190. pictureUrl: this.form.pictureUrl
  191. }
  192. this.goodsList.push(goods)
  193. }
  194. console.log(this.goodsList)
  195. uni.hideLoading();
  196. },
  197. fail: (e) => {
  198. console.log("接口调用失败:" + JSON.stringify(e));
  199. uni.hideLoading();
  200. },
  201. })
  202. },
  203. deleteActivity() {
  204. if (this.form.status == 1) {
  205. this.$api.msg("进行中的活动不能删除,请先停止活动后再进行删除");
  206. return;
  207. }
  208. let that = this;
  209. uni.showModal({
  210. title: '提示',
  211. content: '确定删除这个优惠券吗?',
  212. success: function(res) {
  213. if (res.confirm) {
  214. uni.showLoading({
  215. title: '删除中'
  216. });
  217. var dateStr = (new Date()).getTime();
  218. var sign = that.getSign('' + that.storeInfo.storeId + dateStr);
  219. that.requst({
  220. url: that.deleteStoreCouponUrl,
  221. data: {
  222. timestamp: dateStr,
  223. sign: sign,
  224. storeId: that.storeInfo.storeId,
  225. id: that.form.couponId
  226. },
  227. success: res => {
  228. if (res.data.rtnBean.rtnCode == 0) {
  229. uni.showToast({
  230. title: "删除成功",
  231. duration: 3000,
  232. icon: 'none',
  233. });
  234. // uni.redirectTo({
  235. // url: '/pages/activity/special-item'
  236. // })
  237. let pages = getCurrentPages();
  238. let prevpage = pages[pages.length - 2];
  239. prevpage.$vm.getStoreCouponList();
  240. uni.navigateBack();
  241. } else {
  242. that.$api.msg(res.data.rtnBean.rtnMsg);
  243. }
  244. uni.hideLoading();
  245. },
  246. fail: (e) => {
  247. console.log("接口调用失败:" + JSON.stringify(e));
  248. uni.hideLoading();
  249. },
  250. })
  251. }
  252. }
  253. });
  254. },
  255. handUpdateStatus() {
  256. if (this.form.status == 1) {
  257. if(new Date(this.form.endDate) < new Date()){
  258. this.$api.msg('优惠券结束时间小于当前时间,无法上架,请先修改时间');
  259. return
  260. }
  261. }
  262. this.updateStatus();
  263. },
  264. updateStatus () {
  265. uni.showLoading({
  266. title: '更新中'
  267. });
  268. this.updateStatusVisible = false;
  269. var dateStr = (new Date()).getTime();
  270. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  271. this.requst({
  272. url: this.updateStoreCouponStatusUrl,
  273. data: {
  274. timestamp: dateStr,
  275. sign: sign,
  276. storeId: this.storeInfo.storeId,
  277. id: this.form.couponId,
  278. status: this.form.status == 1 ? 0 : 1
  279. },
  280. success: res => {
  281. if (res.data.rtnBean.rtnCode == 0) {
  282. this.$api.msg("更新成功");
  283. } else {
  284. this.$api.msg(res.data.rtnBean.rtnMsg);
  285. }
  286. this.loadData();
  287. uni.hideLoading();
  288. },
  289. fail: (e) => {
  290. console.log("接口调用失败:" + JSON.stringify(e));
  291. uni.hideLoading();
  292. },
  293. })
  294. },
  295. updateCouponItem () {
  296. if (this.form.status == 1) {
  297. this.$api.msg("进行中的活动不能编辑,请先停止活动后再进行编辑");
  298. return;
  299. }
  300. uni.navigateTo({
  301. url: `/pages/activity/coupon-item-edit?id=${this.form.couponId}`
  302. });
  303. }
  304. },
  305. onLoad (options) {
  306. if (options && options.id) {
  307. this.form.couponId = options.id;
  308. this.loadData();
  309. }
  310. }
  311. }
  312. </script>
  313. <style lang="scss" scoped>
  314. .special-item-info-page {
  315. background-color: #f5f5f5;
  316. border-top: 2rpx solid #f5f5f5;
  317. width: 100vw;
  318. height: 100vh;
  319. }
  320. .scroll-content {
  321. height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
  322. height: calc(100vh - 120rpx - constant(safe-area-inset-bottom));
  323. }
  324. .cell-wrap {
  325. width: 100vw;
  326. padding: 0 40rpx;
  327. box-sizing: border-box;
  328. background-color: #fff;
  329. }
  330. .item:first-child {
  331. padding-top: 40rpx;
  332. }
  333. .item {
  334. @include flexStart;
  335. background-color: #fff;
  336. padding: 20rpx 40rpx;
  337. box-sizing: border-box;
  338. font-size: $font-base;
  339. .label {
  340. width: 240rpx;
  341. color: $desc-color;
  342. }
  343. .value {
  344. width: calc(100% - 240rpx);
  345. @include between;
  346. // overflow: hidden;
  347. // text-overflow: ellipsis;
  348. // word-break: break-all;
  349. // white-space: nowrap;
  350. }
  351. .left {
  352. @include flexStart;
  353. }
  354. .curr-status {
  355. color: $theme-color;
  356. }
  357. .curr-status.ing {
  358. color: $uni-color-button;
  359. }
  360. .update-status {
  361. height: 54rpx;
  362. width: 160rpx;
  363. background-color: $theme-color;
  364. color: #fff;
  365. @include flexCenter;
  366. border-radius: 27rpx;
  367. }
  368. }
  369. .goods-wrap {
  370. .title {
  371. height: 80rpx;
  372. @include flexStart;
  373. padding-left: 40rpx;
  374. box-sizing: border-box;
  375. font-size: $font-base;
  376. color: $text-color;
  377. }
  378. }
  379. .img {
  380. width: 200rpx;
  381. height: 200rpx;
  382. }
  383. .goods {
  384. background-color: #fff;
  385. @include flexStart;
  386. padding: 20rpx;
  387. box-sizing: border-box;
  388. .cover {
  389. width: 166rpx;
  390. height: 166rpx;
  391. border-radius: 10rpx;
  392. margin-right: 24rpx;
  393. .img {
  394. width: 166rpx;
  395. height: 166rpx;
  396. }
  397. }
  398. .cont {
  399. width: calc(100% - 200rpx);
  400. font-size: $font-base;
  401. height: 166rpx;
  402. overflow: hidden;
  403. }
  404. .name {
  405. width: 100%;
  406. text-overflow: -o-ellipsis-lastline;
  407. overflow: hidden;
  408. text-overflow: ellipsis;
  409. display: -webkit-box;
  410. -webkit-line-clamp: 2;
  411. -webkit-box-orient: vertical;
  412. }
  413. .tools {
  414. @include flexStart;
  415. }
  416. .price {
  417. margin-right: 40rpx;
  418. color: $uni-color-button;
  419. }
  420. .origin-price {
  421. color: $desc-color;
  422. text-decoration:line-through;
  423. }
  424. .desc {
  425. color: $desc-color;
  426. }
  427. }
  428. .container {
  429. font-size: $font-base;
  430. }
  431. .update-events {
  432. width: 100vw;
  433. @include flexCenter;
  434. margin-top: 40rpx;
  435. .btn {
  436. width: 80vw;
  437. height: 80rpx;
  438. border-radius: 40rpx;
  439. background-color: $theme-color;
  440. color: #fff;
  441. @include flexCenter;
  442. margin-left: 20rpx;
  443. margin-right: 20rpx;
  444. }
  445. }
  446. </style>