index.vue 6.4 KB

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