clerk.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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 v-if="detail.is_use == 0 && detail.receive_id == 0" class='bottom cross-center'>
  54. <view @click='submit=true'>
  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. export default {
  78. data() {
  79. return {
  80. detail: {
  81. start_time: '',
  82. end_time: ''
  83. },
  84. msg: null,
  85. is_clerk: 0,
  86. submit: false,
  87. cardId: null,
  88. surplus_number: 0,
  89. useNumber: '',
  90. qrCodeId: -1,
  91. }
  92. },
  93. name: "clerk",
  94. methods: {
  95. getList(id) {
  96. let that = this;
  97. that.$showLoading({
  98. text: '加载中...'
  99. });
  100. that.$request({
  101. url: that.$api.card.detailsp,
  102. data: {
  103. cardId: id,
  104. qr_code_id: that.qrCodeId,
  105. },
  106. }).then(response=>{
  107. that.$hideLoading();
  108. if(response.code === 0) {
  109. that.detail = response.data.card;
  110. that.cardId = id;
  111. } else {
  112. uni.showToast({
  113. title: response.msg,
  114. icon: 'none',
  115. duration: 1000,
  116. });
  117. }
  118. if (that.detail.clerk_number && that.detail.clerk_number >= 1) {
  119. uni.showModal({
  120. title: '提示',
  121. content: '核销码已失效',
  122. showCancel: false,
  123. complete: function(res) {
  124. uni.navigateBack();
  125. }
  126. });
  127. };
  128. }).catch(() => {
  129. that.$hideLoading();
  130. });
  131. },
  132. clerk() {
  133. let that = this;
  134. uni.showLoading({
  135. title: '核销中...'
  136. });
  137. if (!that.useNumber) {
  138. uni.showToast({
  139. title: '请输入核销次数',
  140. icon: 'none',
  141. duration: 2000,
  142. });
  143. return false;
  144. }
  145. that.$request({
  146. url: that.$api.card.clerksp,
  147. data: {
  148. cardId: that.cardId,
  149. use_number: that.useNumber,
  150. qr_code_id: that.qrCodeId,
  151. },
  152. }).then(response=>{
  153. uni.hideLoading();
  154. if(response.code === 0) {
  155. that.is_clerk = response.data.is_clerk;
  156. that.msg = response.msg;
  157. that.submit = false;
  158. that.surplus_number = response.data.surplus_number;
  159. } else {
  160. uni.showToast({
  161. title: response.msg,
  162. icon: 'none',
  163. duration: 2000,
  164. });
  165. }
  166. }).catch(() => {
  167. uni.hideLoading();
  168. });
  169. },
  170. closeDialog() {
  171. if (this.msg) {
  172. this.msg = ''
  173. if (this.is_clerk) {
  174. let url = '';
  175. if (this.surplus_number > 0) {
  176. url = '/plugins/clerk/order/order?status=2&type=0';
  177. } else {
  178. url = '/plugins/clerk/order/order?status=2&type=1';
  179. }
  180. uni.navigateBack({});
  181. // uni.redirectTo({
  182. // url: url
  183. // })
  184. }
  185. } else {
  186. this.msg = ''
  187. }
  188. },
  189. },
  190. onLoad(options) {
  191. if(options.qr_code_id) {
  192. this.qrCodeId = options.qr_code_id;
  193. }
  194. this.getList(options.cardId);
  195. }
  196. }
  197. </script>
  198. <style scoped lang="scss">
  199. .box {
  200. display: flex;
  201. flex-direction: column;
  202. .item {
  203. margin-bottom: 140#{rpx};
  204. }
  205. }
  206. .card-info {
  207. margin: 0 24#{rpx};
  208. border-radius: #{15rpx};
  209. background-color: #fff;
  210. position: relative;
  211. margin-top: #{70rpx};
  212. text-align: center;
  213. padding: #{80rpx} #{24rpx} #{36rpx};
  214. margin-bottom: #{20rpx};
  215. }
  216. .card-img {
  217. height: #{88rpx};
  218. width: #{88rpx};
  219. position: absolute;
  220. left: 0;
  221. right: 0;
  222. margin: 0 auto;
  223. top: #{-44rpx};
  224. border-radius: #{44rpx};
  225. }
  226. .card-name {
  227. font-size: #{46rpx};
  228. max-width: 70%;
  229. color: #353535;
  230. margin: 0 auto #{38rpx};
  231. }
  232. .card-status {
  233. width: #{160rpx};
  234. height: #{60rpx};
  235. position: absolute;
  236. bottom: #{30rpx};
  237. left: 0;
  238. right: 0;
  239. margin: 0 auto;
  240. line-height: #{60rpx};
  241. font-size: 15px;
  242. border-radius: #{30rpx};
  243. background-color: #FEEEEE;
  244. color: #FF4544;
  245. }
  246. .card-about {
  247. padding: #{40rpx};
  248. width: 90%;
  249. margin: 0 auto #{50rpx};
  250. border-radius: #{15rpx};
  251. background-color: #fff;
  252. font-size: 15px;
  253. }
  254. .about-title {
  255. color: #999999;
  256. margin-bottom: #{40rpx};
  257. }
  258. .submit-btn {
  259. width: #{702rpx};
  260. height: #{88rpx};
  261. margin: 0 auto;
  262. padding: 0;
  263. text-align: center;
  264. line-height: #{88rpx};
  265. border-radius: #{44rpx};
  266. background-color: #ff4544;
  267. color: #fff;
  268. font-size: #{32rpx};
  269. }
  270. .bottom {
  271. position: fixed;
  272. bottom: 0;
  273. height: #{140rpx};
  274. width: 100%;
  275. padding: 0 #{24rpx};
  276. border-top: #{1rpx} solid #e2e2e2;
  277. background: #ffffff;
  278. }
  279. .order-info {
  280. width: #{702rpx};
  281. margin: #{24rpx};
  282. background-color: #fff;
  283. border-radius: #{16rpx};
  284. padding: #{28rpx} #{24rpx};
  285. font-size: #{28rpx};
  286. color: #353535;
  287. }
  288. .info-label {
  289. color: #999999;
  290. }
  291. .card-other {
  292. text-align: left;
  293. font-size: #{28rpx};
  294. color: #353535;
  295. border-top: #{1rpx} solid #e2e2e2;
  296. }
  297. .other-label {
  298. color: #999999;
  299. margin: #{30rpx} 0 #{22rpx};
  300. }
  301. .bg {
  302. position: fixed;
  303. top: 0;
  304. left: 0;
  305. width: 100%;
  306. height: 100%;
  307. background-color: rgba(0, 0, 0, .3);
  308. z-index: 1000;
  309. }
  310. .dialog {
  311. width: #{630rpx};
  312. background-color: #fff;
  313. padding-top: #{40rpx};
  314. border-radius: #{16rpx};
  315. font-size: #{32rpx};
  316. color: #353535;
  317. text-align: center;
  318. .title {
  319. font-size: 32#{rpx};
  320. color: #353535;
  321. margin-bottom:40#{rpx};
  322. }
  323. }
  324. .dialog-content {
  325. margin: #{40rpx};
  326. display: flex;
  327. justify-content:center;
  328. align-items: center;
  329. .input-number {
  330. width: 288#{rpx};
  331. background: #f7f7f7;
  332. border-radius: 16#{rpx};
  333. height: 80#{rpx};
  334. margin-right: 16#{rpx};
  335. line-height: 80#{rpx};
  336. }
  337. }
  338. .dialog-btn {
  339. color: #ff4544;
  340. height: #{88rpx};
  341. line-height: #{88rpx};
  342. border-top: #{1rpx} solid #e2e2e2;
  343. }
  344. .line {
  345. height: #{45rpx};
  346. width:#{1rpx};
  347. background-color:#e2e2e2;
  348. }
  349. </style>