clerk.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <app-layout>
  3. <view class="box">
  4. <view class="item">
  5. <view class='order-info' v-if="detail.name">
  6. <view class='dir-left-nowrap'>
  7. <view class='info-label'>收货人:</view>
  8. <view>
  9. <view>{{detail.name}}</view>
  10. </view>
  11. </view>
  12. <view class='dir-left-nowrap'>
  13. <view class='info-label'>联系方式:</view>
  14. <view>
  15. <view>{{detail.mobile}}</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="card-info">
  20. <image class="card-img" :src='detail.pic_url'></image>
  21. <view class="card-name t-omit-two">{{detail.card_name}}</view>
  22. <view class='card-other'>
  23. <view class='other-label'>有效时间</view>
  24. <view>{{detail.start_time}} - {{detail.end_time}}</view>
  25. <view class='other-label'>发放时间</view>
  26. <view>{{detail.created_at}}</view>
  27. <view class='other-label'>使用说明</view>
  28. <text>{{detail.content}}</text>
  29. </view>
  30. </view>
  31. <view class='order-info'>
  32. <view style="margin-bottom: 24rpx;">核销信息</view>
  33. <view class='dir-left-nowrap'>
  34. <view class='info-label'>剩余次数:</view>
  35. <view>
  36. <view>{{detail.number - detail.use_number}}次</view>
  37. </view>
  38. </view>
  39. <view class='dir-left-nowrap'>
  40. <view class='info-label'>已核销次数:</view>
  41. <view>
  42. <view>{{detail.use_number}}次</view>
  43. </view>
  44. </view>
  45. <view class='dir-left-nowrap'>
  46. <view class='info-label'>总次数:</view>
  47. <view>
  48. <view>{{detail.number}}次</view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class='bottom cross-center'>
  54. <view @click='submit=true' v-if="detail.is_use == 0">
  55. <button class="submit-btn">核销卡券</button>
  56. </view>
  57. </view>
  58. </view>
  59. <view v-if="msg || submit" class='bg cross-center main-center' @touchmove.stop.prevent="">
  60. <view class='dialog'>
  61. <view class="title">{{submit ? '输入本次核销次数' : '提示'}}</view>
  62. <view v-if="msg" class='dialog-content'>{{msg}}</view>
  63. <view v-if="submit" class='dialog-content'>
  64. <input v-model="useNumber" class="input-number" type="number"/>次
  65. </view>
  66. <view v-if="msg" @click='closeDialog' class='dialog-btn'>确认</view>
  67. <view v-if="submit" class='dialog-btn main-center cross-center'>
  68. <view @click='submit=false' style='color:#666666;width: 50%'>取消</view>
  69. <view class="line"></view>
  70. <view style='width: 50%' @click='clerk'>确定</view>
  71. </view>
  72. </view>
  73. </view>
  74. </app-layout>
  75. </template>
  76. <script>
  77. import { mapState } from "vuex";
  78. export default {
  79. data() {
  80. return {
  81. detail: {
  82. start_time: '',
  83. end_time: ''
  84. },
  85. msg: null,
  86. is_clerk: 0,
  87. submit: false,
  88. cardId: null,
  89. surplus_number: 0,
  90. useNumber: '',
  91. }
  92. },
  93. name: "clerk",
  94. computed: {
  95. ...mapState({
  96. theme: state => state.mallConfig.theme,
  97. })
  98. },
  99. methods: {
  100. getList(id) {
  101. let that = this;
  102. that.$showLoading({
  103. text: '加载中...'
  104. });
  105. that.$request({
  106. url: that.$api.card.detail,
  107. data: {
  108. cardId: id,
  109. },
  110. }).then(response=>{
  111. that.$hideLoading();
  112. if(response.code === 0) {
  113. that.detail = response.data.card;
  114. that.cardId = id;
  115. } else {
  116. uni.showToast({
  117. title: response.msg,
  118. icon: 'none',
  119. duration: 1000,
  120. });
  121. }
  122. }).catch(() => {
  123. that.$hideLoading();
  124. });
  125. },
  126. clerk() {
  127. let that = this;
  128. uni.showLoading({
  129. title: '核销中...'
  130. });
  131. if (!that.useNumber) {
  132. uni.showToast({
  133. title: '请输入核销次数',
  134. icon: 'none',
  135. duration: 2000,
  136. });
  137. return false;
  138. }
  139. that.$request({
  140. url: that.$api.card.clerk,
  141. data: {
  142. cardId: that.cardId,
  143. use_number: that.useNumber
  144. },
  145. }).then(response=>{
  146. uni.hideLoading();
  147. if(response.code === 0) {
  148. that.is_clerk = response.data.is_clerk;
  149. that.msg = response.msg;
  150. that.submit = false;
  151. that.surplus_number = response.data.surplus_number;
  152. } else {
  153. uni.showToast({
  154. title: response.msg,
  155. icon: 'none',
  156. duration: 2000,
  157. });
  158. }
  159. }).catch(() => {
  160. uni.hideLoading();
  161. });
  162. },
  163. closeDialog() {
  164. if (this.msg) {
  165. this.msg = ''
  166. if (this.is_clerk) {
  167. let url = '';
  168. if (this.surplus_number > 0) {
  169. url = '/plugins/clerk/order/order?status=2&type=0';
  170. } else {
  171. url = '/plugins/clerk/order/order?status=2&type=1';
  172. }
  173. uni.navigateBack({});
  174. // uni.redirectTo({
  175. // url: url
  176. // })
  177. }
  178. } else {
  179. this.msg = ''
  180. }
  181. },
  182. },
  183. onLoad(options) {
  184. this.getList(options.cardId);
  185. }
  186. }
  187. </script>
  188. <style scoped lang="scss">
  189. .box {
  190. display: flex;
  191. flex-direction: column;
  192. .item {
  193. margin-bottom: 140#{rpx};
  194. }
  195. }
  196. .card-info {
  197. margin: 0 24#{rpx};
  198. border-radius: #{15rpx};
  199. background-color: #fff;
  200. position: relative;
  201. margin-top: #{70rpx};
  202. text-align: center;
  203. padding: #{80rpx} #{24rpx} #{36rpx};
  204. margin-bottom: #{20rpx};
  205. }
  206. .card-img {
  207. height: #{88rpx};
  208. width: #{88rpx};
  209. position: absolute;
  210. left: 0;
  211. right: 0;
  212. margin: 0 auto;
  213. top: #{-44rpx};
  214. border-radius: #{44rpx};
  215. }
  216. .card-name {
  217. font-size: #{46rpx};
  218. max-width: 70%;
  219. color: #353535;
  220. margin: 0 auto #{38rpx};
  221. }
  222. .card-status {
  223. width: #{160rpx};
  224. height: #{60rpx};
  225. position: absolute;
  226. bottom: #{30rpx};
  227. left: 0;
  228. right: 0;
  229. margin: 0 auto;
  230. line-height: #{60rpx};
  231. font-size: 15px;
  232. border-radius: #{30rpx};
  233. background-color: #FEEEEE;
  234. color: #FF4544;
  235. }
  236. .card-about {
  237. padding: #{40rpx};
  238. width: 90%;
  239. margin: 0 auto #{50rpx};
  240. border-radius: #{15rpx};
  241. background-color: #fff;
  242. font-size: 15px;
  243. }
  244. .about-title {
  245. color: #999999;
  246. margin-bottom: #{40rpx};
  247. }
  248. .submit-btn {
  249. width: #{702rpx};
  250. height: #{88rpx};
  251. margin: 0 auto;
  252. padding: 0;
  253. text-align: center;
  254. line-height: #{88rpx};
  255. border-radius: #{44rpx};
  256. background-color: #ff4544;
  257. color: #fff;
  258. font-size: #{32rpx};
  259. }
  260. .bottom {
  261. position: fixed;
  262. bottom: 0;
  263. height: #{140rpx};
  264. width: 100%;
  265. padding: 0 #{24rpx};
  266. border-top: #{1rpx} solid #e2e2e2;
  267. background: #ffffff;
  268. }
  269. .order-info {
  270. width: #{702rpx};
  271. margin: #{24rpx};
  272. background-color: #fff;
  273. border-radius: #{16rpx};
  274. padding: #{28rpx} #{24rpx};
  275. font-size: #{28rpx};
  276. color: #353535;
  277. }
  278. .info-label {
  279. color: #999999;
  280. }
  281. .card-other {
  282. text-align: left;
  283. font-size: #{28rpx};
  284. color: #353535;
  285. border-top: #{1rpx} solid #e2e2e2;
  286. }
  287. .other-label {
  288. color: #999999;
  289. margin: #{30rpx} 0 #{22rpx};
  290. }
  291. .bg {
  292. position: fixed;
  293. top: 0;
  294. left: 0;
  295. width: 100%;
  296. height: 100%;
  297. background-color: rgba(0, 0, 0, .3);
  298. z-index: 1000;
  299. }
  300. .dialog {
  301. width: #{630rpx};
  302. background-color: #fff;
  303. padding-top: #{40rpx};
  304. border-radius: #{16rpx};
  305. font-size: #{32rpx};
  306. color: #353535;
  307. text-align: center;
  308. .title {
  309. font-size: 32#{rpx};
  310. color: #353535;
  311. margin-bottom:40#{rpx};
  312. }
  313. }
  314. .dialog-content {
  315. margin: #{40rpx};
  316. display: flex;
  317. justify-content:center;
  318. align-items: center;
  319. .input-number {
  320. width: 288#{rpx};
  321. background: #f7f7f7;
  322. border-radius: 16#{rpx};
  323. height: 80#{rpx};
  324. margin-right: 16#{rpx};
  325. line-height: 80#{rpx};
  326. }
  327. }
  328. .dialog-btn {
  329. color: #ff4544;
  330. height: #{88rpx};
  331. line-height: #{88rpx};
  332. border-top: #{1rpx} solid #e2e2e2;
  333. }
  334. .line {
  335. height: #{45rpx};
  336. width:#{1rpx};
  337. background-color:#e2e2e2;
  338. }
  339. </style>