index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <view class="pages">
  3. <view class="" :style="{height: navHeight+'px' }"></view>
  4. <view class="page-wrap">
  5. <view class="title-wrap">
  6. <img style="width: 226rpx;height: 108rpx" src="../../static/img/index-title.png" alt="">
  7. </view>
  8. <view class="search-wrap u-flex">
  9. <u-search
  10. placeholder="请输入核销码"
  11. color="#009AEF"
  12. searchIconColor="#009AEF"
  13. bgColor="#F5F9FC"
  14. @search="getCheckGoods"
  15. @custom="getCheckGoods"
  16. @clear="clearCode"
  17. :inputStyle="{height:'88rpx'}"
  18. :actionStyle="{'background-color':'#3ebbff',width:'88rpx',height:'88rpx','line-height':'88rpx',color:'#fff','border-radius':'16rpx'}"
  19. v-model="exchangeCode">
  20. </u-search>
  21. <view class="qr-link" @click="openScan"></view>
  22. </view>
  23. <view class="goods-wrap" v-if="showResult&&showEmpty==false">
  24. <view class="title">搜索结果</view>
  25. <view class="goods u-flex u-col-top">
  26. <img class="img" :src="checkGoods.mainImg" alt="">
  27. <view class="text">
  28. <view class="title ellipsis-2">{{checkGoods.goodsName}}</view>
  29. <view class="credit">{{checkGoods.credit}}积分</view>
  30. <view class="bottom u-flex u-row-between">
  31. <view class="left">
  32. <view class="quantity">兑换数量:{{checkGoods.quantity}}</view>
  33. <view class="userinfo">姓名:{{checkGoods.name}} / {{checkGoods.dept}} </view>
  34. </view>
  35. <u-button
  36. @click.native.stop="check()"
  37. type="primary"
  38. :customStyle="{height:'58rpx',width: 'auto','margin-right': 'unset'}"
  39. text="核销">
  40. </u-button>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <u-empty mode="data" :text="emptyText" v-if="showEmpty&&!showResult"></u-empty>
  46. <tabbar :tabbarIndexProps='0' />
  47. </view>
  48. <u-toast ref="uToast"></u-toast>
  49. </view>
  50. </template>
  51. <script>
  52. import { systemInfo } from "@/mixin.js";
  53. import {
  54. BrowserMultiFormatReader,
  55. ChecksumException,
  56. FormatException,
  57. } from "@zxing/library";
  58. import { LOG } from "@zxing/library/esm/core/datamatrix/encoder/constants";
  59. import tabbar from "../../components/tabbar.vue";
  60. export default {
  61. components:{
  62. tabbar,
  63. },
  64. mixins:[systemInfo],
  65. data() {
  66. return {
  67. exchangeCode:'',
  68. checkGoods:{},
  69. showResult:false,
  70. emptyText:'',
  71. showEmpty:false,
  72. }
  73. },
  74. onLoad() {
  75. let that = this;
  76. // this.initEvent()
  77. },
  78. mounted() {
  79. },
  80. onShow() {
  81. this.exchangeCode = this.vuexExchangeCode;
  82. },
  83. beforeDestroy() {
  84. },
  85. watch: {
  86. exchangeCode:{
  87. handler(val){
  88. if(val.length>=8){
  89. this.getCheckGoods()
  90. }
  91. }
  92. }
  93. },
  94. methods: {
  95. getCheckGoods(){
  96. this.$u.api.getCheckGood({exchangeCode:this.exchangeCode}).then(res=>{
  97. this.checkGoods = res.data;
  98. this.showResult = true;
  99. this.showEmpty = false;
  100. // console.log('getCheckGood',this.checkGoods);
  101. }).catch(err=>{
  102. this.showEmpty = true;
  103. this.showResult = false;
  104. this.emptyText = err.msg;
  105. console.log('getCheckGood',err);
  106. })
  107. },
  108. clearCode(){
  109. this.showEmpty = true;
  110. this.showResult = true;
  111. },
  112. check(){//核销
  113. this.$u.api.check({exchangeCode:this.exchangeCode}).then(res=>{
  114. this.checkGoods = {};
  115. this.showResult = false;
  116. uni.showToast({
  117. title:res.msg,
  118. icon:"success"
  119. })
  120. this.$u.vuex('vuexExchangeCode', '');
  121. uni.reLaunch({url: `/center/checksuccess?success=true`});
  122. // console.log('check',this.checkGoods);
  123. }).catch(err=>{
  124. console.log('check',err);
  125. })
  126. },
  127. async openScan() {
  128. // uni.$u.route('/center/scan');
  129. uni.navigateTo({
  130. url:'/center/scan',
  131. fail(e) {
  132. console.log('navigateTo',e);
  133. }
  134. })
  135. },
  136. }
  137. }
  138. </script>
  139. <style>
  140. page{
  141. background-color: #fff;
  142. }
  143. </style>
  144. <style lang="scss" scoped>
  145. .title-wrap{
  146. text-align: center;
  147. margin: 100rpx auto 60rpx;
  148. }
  149. .qr-link{
  150. margin-left: 10rpx;
  151. width: 88rpx;
  152. height: 88rpx;
  153. background: url(../../static/img/qr-ico.png) no-repeat center;
  154. background-color: rgba(0,154,239,0.2);
  155. border-radius: 16rpx;
  156. }
  157. .loop_line {
  158. height: 3px;
  159. width: 80%;
  160. background-color: aliceblue;
  161. border-radius: 50%;
  162. box-shadow: 1px -4px 25px 7px rgba(255, 255, 255, 0.5);
  163. position: absolute;
  164. left: 50%;
  165. top: 5%;
  166. transform: translateX(-50%);
  167. animation: myfirst 3s infinite;
  168. z-index: 999999;
  169. }
  170. @keyframes myfirst {
  171. from {
  172. top: 5%;
  173. }
  174. to {
  175. top: 80%;
  176. }
  177. }
  178. #video_nav_id {
  179. height: 100%;
  180. width: 100%;
  181. }
  182. /deep/.uni-video-cover {
  183. display: none;
  184. }
  185. .scan {
  186. position: fixed;
  187. left: 0;
  188. top: 0;
  189. z-index: 99;
  190. display: flex;
  191. flex-direction: column;
  192. align-items: center;
  193. color: #ff9900;
  194. width: 100%;
  195. height: 100vh;
  196. background: #000;
  197. .video-container {
  198. width: 100%;
  199. height: 100%;
  200. display: flex;
  201. justify-content: center;
  202. /deep/ #video-1{
  203. width: 100%;
  204. height: 100%;
  205. }
  206. @media (min-width: 500px) {
  207. video {
  208. // width: 80vh;
  209. max-width: 96vw;
  210. height: 80vh;
  211. }
  212. }
  213. }
  214. .camera-container {
  215. margin-top: 5vh;
  216. width: 80%;
  217. height: 50px;
  218. line-height: 44px;
  219. border-radius: 10px;
  220. border: 3px solid #ff9900;
  221. display: flex;
  222. justify-content: center;
  223. select {
  224. width: calc(100% - 80px);
  225. color: #ff9900;
  226. background: transparent;
  227. border: none;
  228. outline: none;
  229. }
  230. }
  231. .close{
  232. position: absolute;
  233. right: 40rpx;
  234. top: 40rpx;
  235. z-index: 100;
  236. }
  237. }
  238. .goods-wrap{
  239. margin-top: 42rpx;
  240. .title{
  241. font-size: 32rpx;
  242. font-weight: 400;
  243. color: #999999;
  244. line-height: 44rpx;
  245. margin-bottom: 20rpx;
  246. }
  247. .goods{
  248. padding: 28rpx 0;
  249. background-color: #fff;
  250. .img{
  251. width: 200rpx;
  252. height: 202rpx;
  253. }
  254. .text{
  255. flex: 1;
  256. margin-left: 40rpx;
  257. .title{
  258. font-size: 30rpx;
  259. font-family: PingFangSC-Regular, PingFang SC;
  260. font-weight: 400;
  261. color: #333333;
  262. line-height: 42rpx;
  263. margin-bottom: 20rpx;
  264. }
  265. .credit{
  266. font-size: 32rpx;
  267. font-family: PingFangSC-Semibold, PingFang SC;
  268. font-weight: 600;
  269. color: #FFB100;
  270. line-height: 44rpx;
  271. margin-bottom: 20rpx;
  272. }
  273. .left{
  274. font-size: 28rpx;
  275. font-family: PingFangSC-Regular, PingFang SC;
  276. font-weight: 400;
  277. color: #999999;
  278. line-height: 40rpx;
  279. }
  280. }
  281. &:not(:last-of-type){
  282. border-bottom: 0.5px solid #ddd;
  283. padding-bottom: 20rpx;
  284. }
  285. }
  286. }
  287. </style>