index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. uni.reLaunch({url: `/center/checksuccess?success=true`});
  121. // console.log('check',this.checkGoods);
  122. }).catch(err=>{
  123. console.log('check',err);
  124. })
  125. },
  126. async openScan() {
  127. // uni.$u.route('/center/scan');
  128. uni.navigateTo({
  129. url:'/center/scan',
  130. fail(e) {
  131. console.log('navigateTo',e);
  132. }
  133. })
  134. },
  135. }
  136. }
  137. </script>
  138. <style>
  139. page{
  140. background-color: #fff;
  141. }
  142. </style>
  143. <style lang="scss" scoped>
  144. .title-wrap{
  145. text-align: center;
  146. margin: 100rpx auto 60rpx;
  147. }
  148. .qr-link{
  149. margin-left: 10rpx;
  150. width: 88rpx;
  151. height: 88rpx;
  152. background: url(../../static/img/qr-ico.png) no-repeat center;
  153. background-color: rgba(0,154,239,0.2);
  154. border-radius: 16rpx;
  155. }
  156. .loop_line {
  157. height: 3px;
  158. width: 80%;
  159. background-color: aliceblue;
  160. border-radius: 50%;
  161. box-shadow: 1px -4px 25px 7px rgba(255, 255, 255, 0.5);
  162. position: absolute;
  163. left: 50%;
  164. top: 5%;
  165. transform: translateX(-50%);
  166. animation: myfirst 3s infinite;
  167. z-index: 999999;
  168. }
  169. @keyframes myfirst {
  170. from {
  171. top: 5%;
  172. }
  173. to {
  174. top: 80%;
  175. }
  176. }
  177. #video_nav_id {
  178. height: 100%;
  179. width: 100%;
  180. }
  181. /deep/.uni-video-cover {
  182. display: none;
  183. }
  184. .scan {
  185. position: fixed;
  186. left: 0;
  187. top: 0;
  188. z-index: 99;
  189. display: flex;
  190. flex-direction: column;
  191. align-items: center;
  192. color: #ff9900;
  193. width: 100%;
  194. height: 100vh;
  195. background: #000;
  196. .video-container {
  197. width: 100%;
  198. height: 100%;
  199. display: flex;
  200. justify-content: center;
  201. /deep/ #video-1{
  202. width: 100%;
  203. height: 100%;
  204. }
  205. @media (min-width: 500px) {
  206. video {
  207. // width: 80vh;
  208. max-width: 96vw;
  209. height: 80vh;
  210. }
  211. }
  212. }
  213. .camera-container {
  214. margin-top: 5vh;
  215. width: 80%;
  216. height: 50px;
  217. line-height: 44px;
  218. border-radius: 10px;
  219. border: 3px solid #ff9900;
  220. display: flex;
  221. justify-content: center;
  222. select {
  223. width: calc(100% - 80px);
  224. color: #ff9900;
  225. background: transparent;
  226. border: none;
  227. outline: none;
  228. }
  229. }
  230. .close{
  231. position: absolute;
  232. right: 40rpx;
  233. top: 40rpx;
  234. z-index: 100;
  235. }
  236. }
  237. .goods-wrap{
  238. margin-top: 42rpx;
  239. .title{
  240. font-size: 32rpx;
  241. font-weight: 400;
  242. color: #999999;
  243. line-height: 44rpx;
  244. margin-bottom: 20rpx;
  245. }
  246. .goods{
  247. padding: 28rpx 0;
  248. background-color: #fff;
  249. .img{
  250. width: 200rpx;
  251. height: 202rpx;
  252. }
  253. .text{
  254. flex: 1;
  255. margin-left: 40rpx;
  256. .title{
  257. font-size: 30rpx;
  258. font-family: PingFangSC-Regular, PingFang SC;
  259. font-weight: 400;
  260. color: #333333;
  261. line-height: 42rpx;
  262. margin-bottom: 20rpx;
  263. }
  264. .credit{
  265. font-size: 32rpx;
  266. font-family: PingFangSC-Semibold, PingFang SC;
  267. font-weight: 600;
  268. color: #FFB100;
  269. line-height: 44rpx;
  270. margin-bottom: 20rpx;
  271. }
  272. .left{
  273. font-size: 28rpx;
  274. font-family: PingFangSC-Regular, PingFang SC;
  275. font-weight: 400;
  276. color: #999999;
  277. line-height: 40rpx;
  278. }
  279. }
  280. &:not(:last-of-type){
  281. border-bottom: 0.5px solid #ddd;
  282. padding-bottom: 20rpx;
  283. }
  284. }
  285. }
  286. </style>