clerk.vue 12 KB

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