index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <base-page>
  3. <view class="uni-flex uni-row height-all">
  4. <view class="container common-wrap" style="-webkit-flex: 1;flex: 1;" v-if="step == 'search'">
  5. <view class="search-title">查询核销码核销</view>
  6. <view class="search-wrap">
  7. <view class="input-wrap">
  8. <input type="text" value="" placeholder="请输入核销码或扫描核销码" placeholder-class="placeholder" v-model="code" @confirm="search" focus />
  9. <!-- #ifdef APP-PLUS -->
  10. <view class="iconfont iconsaoyisaosaoma" @click="scancode"></view>
  11. <!-- #endif -->
  12. </view>
  13. <button type="default" class="primary-btn" @click="search">查询</button>
  14. </view>
  15. <view class="search-desc">使用扫码枪扫码时需注意光标需要停留在输入框中</view>
  16. <view class="record" @click="$util.redirectTo('/pages/verify/list')"><text>核销记录</text></view>
  17. </view>
  18. <view class="content-box common-wrap" style="-webkit-flex: 1;flex: 1;" v-if="step == 'verify'">
  19. <view class="input-wrap">
  20. <input placeholder="请输入核销码" v-model="code" @confirm="search" />
  21. <button type="default" class="primary-btn search" @click="search()">查询</button>
  22. </view>
  23. <view class="content-data">
  24. <view class="content-top">
  25. <view v-for="(item, index) in verifyInfo.data.item_array" :key="index" class="verify-item">
  26. <view class="container-image"><image :src="$util.img(item.img.split(',')[0], { size: 'small' })" mode="aspectFit"></image></view>
  27. <view class="container-box">
  28. <view class="content-name">{{ item.name }}</view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="content-bottom">
  33. <view class="bottom-item">
  34. <view>核销状态:{{ verifyInfo.is_verify == 0 ? '待核销' : '已核销' }}</view>
  35. </view>
  36. <view class="bottom-item">
  37. <view>核销类型:{{ verifyInfo.verify_type_name }}核销</view>
  38. </view>
  39. <view class="bottom-item">
  40. <view>总次数/已使用:{{ verifyInfo.verify_total_count ? verifyInfo.verify_total_count : '不限' }}次/{{ verifyInfo.verify_use_num }}次</view>
  41. </view>
  42. <view class="bottom-item">
  43. <view>有效期:{{ verifyInfo.expire_time ? $util.timeFormat(verifyInfo.expire_time, 'y-m-d h:i') : '永久' }}</view>
  44. </view>
  45. </view>
  46. <view class="verify-action">
  47. <button type="primary" class="default-btn" @click="step = 'search'">取消</button>
  48. <button type="default" class="primary-btn" @click="verify()" v-show="verifyInfo.is_verify == 0">立即核销</button>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </base-page>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. step: 'search',
  60. code: '',
  61. verifyInfo: null,
  62. isRepeat: false
  63. };
  64. },
  65. onLoad() {
  66. uni.hideTabBar({});
  67. },
  68. methods: {
  69. deleteCode() {
  70. this.code = this.code.substr(0, this.code.length - 1);
  71. },
  72. search() {
  73. if (!this.code) {
  74. this.$util.showToast({ title: '请输入核销码' });
  75. return;
  76. }
  77. setTimeout(() => {
  78. this.$api.sendRequest({
  79. url: '/cashier/storeapi/verify/info',
  80. data: { code: this.code.trim() },
  81. success: res => {
  82. this.code = '';
  83. if (res.code >= 0) {
  84. this.verifyInfo = res.data;
  85. this.step = 'verify';
  86. } else {
  87. this.$util.showToast({ title: res.message });
  88. }
  89. }
  90. });
  91. }, 200);
  92. },
  93. verify() {
  94. if (!this.verifyInfo) {
  95. this.$util.showToast({ title: '请先查询核销码信息' });
  96. return;
  97. }
  98. if (this.isRepeat) return;
  99. this.isRepeat = true;
  100. this.$api.sendRequest({
  101. url: '/cashier/storeapi/verify/verify',
  102. data: { verify_code: this.verifyInfo.verify_code },
  103. success: res => {
  104. this.isRepeat = false;
  105. if (res.code >= 0) {
  106. this.step = 'search';
  107. this.verifyInfo = null;
  108. this.code = '';
  109. }
  110. this.$util.showToast({ title: res.message });
  111. }
  112. });
  113. },
  114. scancode() {
  115. uni.scanCode({
  116. scanType: ['qrCode', 'barCode'],
  117. success: res => {
  118. this.code = res.result;
  119. this.search();
  120. },
  121. fail: res => {
  122. this.$util.showToast({ title: '扫码失败' });
  123. }
  124. });
  125. }
  126. }
  127. };
  128. </script>
  129. <style lang="scss" scoped>
  130. .container {
  131. display: flex;
  132. align-items: center;
  133. justify-content: center;
  134. flex-direction: column;
  135. }
  136. .search-title {
  137. font-size: 0.18rem;
  138. color: #303133;
  139. }
  140. .search-wrap {
  141. display: flex;
  142. margin-top: 0.3rem;
  143. button {
  144. width: 1rem;
  145. text-align: center;
  146. box-sizing: border-box;
  147. line-height: 0.5rem;
  148. }
  149. }
  150. .search-desc {
  151. color: #909399;
  152. font-size: 0.14rem;
  153. margin-top: 0.3rem;
  154. }
  155. .input-wrap {
  156. width: 4.5rem;
  157. height: 0.5rem;
  158. border: 0.01rem solid #cccccc;
  159. display: flex;
  160. border-radius: 0.02rem;
  161. align-items: center;
  162. input {
  163. flex: 1;
  164. padding: 0 0.15rem;
  165. font-size: 0.16rem;
  166. }
  167. .placeholder {
  168. flex: 1;
  169. height: 0.58rem;
  170. line-height: 0.58rem;
  171. font-size: 0.16rem;
  172. font-weight: 400;
  173. color: #909399;
  174. }
  175. .iconfont {
  176. font-size: 0.18rem;
  177. padding: 0 0.15rem;
  178. font-weight: bold;
  179. }
  180. }
  181. .record {
  182. text-align: center;
  183. margin-top: 0.2rem;
  184. text {
  185. color: $primary-color;
  186. font-size: 0.14rem;
  187. cursor: pointer;
  188. }
  189. }
  190. // 核销详情
  191. .content-box {
  192. padding: 0.15rem 0.15rem 0.15rem 0.15rem;
  193. .input-wrap {
  194. width: 6rem;
  195. height: 0.4rem;
  196. border: 0.01rem solid #cccccc;
  197. display: flex;
  198. border-radius: 0.02rem;
  199. input {
  200. flex: 1;
  201. padding: 0 0.15rem;
  202. height: 0.38rem;
  203. line-height: 0.38rem;
  204. font-size: 0.16rem;
  205. font-weight: 400;
  206. }
  207. .placeholder {
  208. font-weight: 400;
  209. color: #909399;
  210. font-size: 0.18rem;
  211. }
  212. .search {
  213. border-radius: 0;
  214. width: 1rem;
  215. line-height: 0.38rem;
  216. font-size: 0.16rem;
  217. font-family: Source Han Sans CN;
  218. &::after {
  219. border: none;
  220. }
  221. }
  222. }
  223. .content-data {
  224. border: 0.01rem solid #eee;
  225. margin-top: 0.2rem;
  226. padding: 0.15rem;
  227. .verify-item {
  228. display: flex;
  229. padding: 0.15rem 0;
  230. .container-image {
  231. width: 1rem;
  232. height: 1rem;
  233. image {
  234. width: 100%;
  235. height: 100%;
  236. }
  237. }
  238. .container-box {
  239. margin-left: 0.15rem;
  240. width: 0;
  241. flex: 1;
  242. .content-name {
  243. font-size: 0.15rem;
  244. margin-top: 0.05rem;
  245. }
  246. .content-desc {
  247. display: flex;
  248. margin-top: 0.15rem;
  249. color: #999;
  250. font-size: 0.13rem;
  251. .time {
  252. margin-left: 0.5rem;
  253. }
  254. }
  255. }
  256. }
  257. .verify-action {
  258. display: flex;
  259. justify-content: flex-end;
  260. border-top: 0.01rem solid #eee;
  261. padding-top: 0.15rem;
  262. button {
  263. width: 1rem;
  264. height: 0.36rem;
  265. margin: 0 0 0 0.15rem;
  266. }
  267. }
  268. .content-bottom {
  269. padding: 0.15rem 0;
  270. border-top: 0.01rem solid #eee;
  271. .bottom-item {
  272. color: #999;
  273. display: flex;
  274. margin-top: 0.15rem;
  275. width: 5rem;
  276. justify-content: space-between;
  277. view {
  278. margin-right: 0.5rem;
  279. }
  280. }
  281. }
  282. }
  283. }
  284. </style>