index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. <template>
  2. <view>
  3. <view class="content">
  4. <view class="header-box">
  5. <UniStatusBar></UniStatusBar>
  6. <view class="title flex align_center" :style="{height:(navHeight+'px')}">
  7. <u-image src="/static/logo-h.png" width="349" height='40'></u-image>
  8. </view>
  9. </view>
  10. <view class="cbody">
  11. <view class="body-box bg-blue">
  12. <!-- 滚动区域 -->
  13. <view class="scroll-list">
  14. <scrollBox v-if="list.length" :list="list"></scrollBox>
  15. </view>
  16. <!-- 保证金 -->
  17. <view class="notices flex align_center" v-if="bondRecord" @click="toPayBondAmount">
  18. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有一笔保证金待支付 ¥{{bondRecord.bondAmount}}</view>
  19. <!-- <text class="text">立即支付>></text> -->
  20. </view>
  21. <!-- 待取货提醒 -->
  22. <view class="notices flex align_center" v-if="!bondRecord&&orderTodo" @click="toOrder">
  23. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有待取货的货架订单哦!</view> <text class="text">立即处理>></text>
  24. </view>
  25. <!-- 门店审核不通过 -->
  26. <view class="notices flex justify_between" v-if="storeApply&&storeApply.auditStatus=='REFUSE'&&storeApply.readFlag=='0'">
  27. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 门店认证资料审核不通过,请重新提交审核!</view> <text class="text" @click="toKnow">知道了</text>
  28. </view>
  29. <!-- 名片 -->
  30. <view class="userCard flex align_center justify_between">
  31. <view class="userCard-info flex align_center">
  32. <view>
  33. <u-image shape='circle' v-if="!hasLogin" src="/static/def_personal_avatar.png" width="90" height="90"></u-image>
  34. <u-image shape='circle' v-else :src="avatarUrl||'/static/def_personal_avatar.png'" width="90" height="90"></u-image>
  35. </view>
  36. <view class="user-info" @click="toUser">
  37. <view v-if="!hasLogin" style="font-size: 40rpx;">
  38. 请点击登录
  39. </view>
  40. <view v-else>
  41. <view class="user-name">{{userInfo.userNameCN || userInfo.mobile}}</view>
  42. <view v-if="hasLogin&&userInfo&&userInfo.sysUserFlag == '0'">
  43. <u-tag text="个人用户" mode="dark" type="warning" shape="circle" size="mini" />
  44. </view>
  45. <view v-else>{{userInfo.orgName}}</view>
  46. </view>
  47. </view>
  48. </view>
  49. <view @click="toUser">
  50. <text v-if="hasLogin&&userInfo&&userInfo.sysUserFlag == '0'" class="user-rz">
  51. {{storeApply&&storeApply.auditStatus=='WAIT'?'认证门店审核中':'认证成为门店'}}
  52. </text>
  53. <u-icon name="arrow-right"></u-icon>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="body-box">
  58. <!-- 扫描按钮 -->
  59. <!-- <view class="scanButton flex align_center" @click="openCamera">
  60. <u-icon name="scan" size="60"></u-icon><text class="ml10">扫描VIN</text>
  61. </view> -->
  62. <!-- 直接取货 -->
  63. <view class="scanButton flex align_center" v-if="userInfo.sysUserFlag == '1'" @click="openTakeGood">
  64. <text>没有VIN,直接取货</text>
  65. </view>
  66. <view class="flex align_center justify_center">
  67. <u-image src="/static/banner1.png" width="645" height="504"></u-image>
  68. </view>
  69. <u-action-sheet :list="actionList" @click="clickAction" v-model="showAction"></u-action-sheet>
  70. </view>
  71. <!-- 扫描记录 -->
  72. <view class="list-box">
  73. <!-- 扫描记录 -->
  74. <u-cell-group :border="false">
  75. <u-cell-item title="VIN查询历史" @click="toAllRecord" :title-style="{fontSize:'1em'}" value="全部">
  76. <u-icon slot="icon" size="38" color="#066cff" style="margin-right: 0.3em;" name="order"></u-icon>
  77. </u-cell-item>
  78. </u-cell-group>
  79. <u-cell-group :border="false" v-if="hasLogin">
  80. <u-cell-item v-for="item in vinList"
  81. @click="toChoosePart(item)"
  82. :key="item.id"
  83. :title="item.vinCode"
  84. :title-style="{fontSize:'1em'}"
  85. :label="userInfo&&userInfo.sysUserFlag == '0' ? item.createDate : (item.brandName +' '+item.modelName)">
  86. <text slot="icon"></text>
  87. </u-cell-item>
  88. <view style="padding: 20upx;">
  89. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="vinList.length==0 && status!='loading'" mode="list"></u-empty>
  90. <u-loadmore v-if="status=='loading'" :status="status" />
  91. </view>
  92. </u-cell-group>
  93. <view class="des" v-if="vinList.length&&hasLogin">仅展示最近5条记录,点击“全部”查看更多</view>
  94. <view class="des" v-if="!hasLogin">请登录后查看历史记录</view>
  95. </view>
  96. </view>
  97. </view>
  98. <u-tabbar :list="vuex_tabBarList" :before-switch="beforeSwitch" :mid-button="true"></u-tabbar>
  99. </view>
  100. </template>
  101. <script>
  102. import {
  103. mapState,
  104. mapMutations,
  105. } from 'vuex'
  106. import scrollBox from '@/components/scrollBox.vue'
  107. import UniStatusBar from '@/components/uni-status-bar/uni-status-bar.vue'
  108. import { shelfBondRecordWaitPayRecord, findStoreShelf, shelfGetTotalWaitQty, getProductfindByScanCode, findPriceShow,findPriceShowType,findPriceShowEmployee } from '@/api/shelf.js'
  109. import { xprhStoreApplyRead } from '@/api/xprh.js'
  110. import { listLookUp, getLookUpDatas } from '@/api/data.js';
  111. import { scanVinLogQueryRoll, getScanVinLogList, getScanGetMaxQty }from '@/api/car.js'
  112. export default {
  113. components: {
  114. scrollBox,
  115. UniStatusBar
  116. },
  117. data() {
  118. return {
  119. status: 'loading',
  120. noDataText: '暂无数据',
  121. bondRecord: null, // 保证金
  122. list:[],
  123. vinList: [],
  124. orderTodo: null,
  125. avatarUrl:'',
  126. navHeight: '44',
  127. scanMaxNums: 10,
  128. showAction: false,
  129. actionList: [
  130. {
  131. text: '扫描条形码/二维码',
  132. fontSize: 32
  133. },
  134. {
  135. text: '按产品编码查询',
  136. fontSize: 32
  137. }
  138. ]
  139. }
  140. },
  141. computed: {
  142. ...mapState(['hasLogin','vuex_vinScanNums','vuex_tabBarList']),
  143. hasShelf(){
  144. return this.$store.state.vuex_storeShelf
  145. },
  146. userInfo(){
  147. return this.$store.state.vuex_userInfo
  148. },
  149. storeApply(){
  150. return this.$store.state.vuex_storeAuthInfo || null
  151. }
  152. },
  153. onReady() {
  154. this.getScrollLog()
  155. // 获取导航栏高度
  156. const res = uni.getSystemInfoSync()
  157. const system = res.platform
  158. if (system === 'android') {
  159. this.navHeight = 48
  160. } else if (system === 'ios') {
  161. this.navHeight = 44
  162. }
  163. },
  164. onLoad() {
  165. this.orderTodo = null
  166. this.bondRecord = null
  167. this.vinList = []
  168. // 检测是否登录
  169. this.$store.dispatch('checkLogin',()=>{
  170. // 获取数据字典
  171. this.getListLookUp();
  172. // 获取支付,收款方式
  173. this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
  174. // 价格类型
  175. this.getLookUpList('PRICE_SHOW_TYPE', 'vuex_priceTypeList');
  176. // 初始化页面
  177. this.pageInit()
  178. })
  179. // 刷新首页数据
  180. uni.$on("refashHome",()=>{
  181. this.pageInit()
  182. })
  183. },
  184. onUnload() {
  185. uni.$off('refashHome')
  186. },
  187. // 下拉刷新
  188. onPullDownRefresh(){
  189. this.pageInit()
  190. setTimeout(function () {
  191. uni.stopPullDownRefresh();
  192. }, 1000);
  193. },
  194. onShareAppMessage() {},
  195. onShow() {
  196. // 用户头像
  197. this.avatarUrl = uni.getStorageSync('userPhoto');
  198. if(this.hasLogin){
  199. // 查询门店认证信息
  200. if(this.userInfo.sysUserFlag == '0'){
  201. this.findLastApply()
  202. }
  203. }
  204. },
  205. methods: {
  206. beforeSwitch(index){
  207. if(index==1){
  208. this.openCamera()
  209. }else{
  210. return true
  211. }
  212. },
  213. async getPriceShow(){
  214. await findPriceShow().then(res => {
  215. this.showPrice = res.data ? res.data.paramValue=='1' : false
  216. this.$store.state.vuex_showPrice[0] = this.showPrice
  217. })
  218. await findPriceShowType().then(res => {
  219. if(res.data&&res.data.paramValue){
  220. this.priceType = res.data.paramValue
  221. this.priceTypeName = this.$store.state.vuex_priceTypeList.find(item => item.code == res.data.paramValue).dispName
  222. this.$store.state.vuex_showPrice[1] = this.priceType
  223. }
  224. })
  225. await findPriceShowEmployee().then(res => {
  226. this.showJhPrice = res.data ? res.data.paramValue=='1' : false
  227. this.$store.state.vuex_showPrice[2] = this.showJhPrice
  228. })
  229. },
  230. pageInit(){
  231. if(this.hasLogin){
  232. // 获取扫描记录
  233. this.getVinLog()
  234. // 非游客
  235. if(this.userInfo.sysUserFlag == '1'){
  236. // 查询是否有数字货架
  237. this.getStoreShelf()
  238. }else{
  239. // 获取扫描次数
  240. this.$store.dispatch("getScanNums")
  241. // 获取最大扫描次数
  242. this.getMaxQty()
  243. // 查询门店认证信息
  244. this.findLastApply()
  245. }
  246. }else{
  247. uni.removeStorageSync('token')
  248. }
  249. },
  250. // 获取数据字典
  251. getListLookUp() {
  252. const _this = this;
  253. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  254. if (res.status == 200) {
  255. _this.$store.state.vuex_allLookUp = res.data;
  256. }
  257. });
  258. },
  259. // 或某一项字典列表,参数code
  260. getLookUpList(code, vuexKey) {
  261. getLookUpDatas({ type: code }).then(res => {
  262. if (res.status == 200) {
  263. this.$store.state[vuexKey] = res.data || [];
  264. if(code=='PRICE_SHOW_TYPE'){
  265. // 获取显示价格类型
  266. this.getPriceShow()
  267. }
  268. }
  269. });
  270. },
  271. // 获取最大扫描数
  272. getMaxQty(){
  273. getScanGetMaxQty().then(res => {
  274. this.scanMaxNums = res.data || 10
  275. this.$store.state.vuex_scanMaxNums = this.scanMaxNums
  276. })
  277. },
  278. // 获取最新申请门店
  279. findLastApply(){
  280. const mobile = this.userInfo.mobile
  281. this.$store.dispatch('getSotreAuth',mobile)
  282. },
  283. // 知道审核不通过
  284. toKnow(){
  285. uni.showLoading({
  286. title: "正在提交"
  287. })
  288. xprhStoreApplyRead({sn:this.storeApply.applySn}).then(res => {
  289. if(res.status == 200){
  290. this.findLastApply()
  291. }
  292. uni.hideLoading()
  293. })
  294. },
  295. // 待取货数量合计
  296. shelfGetTotalWaitQty(){
  297. shelfGetTotalWaitQty({billState:'WAIT'}).then(res => {
  298. if(res.status == 200){
  299. this.orderTodo = res.data;
  300. }
  301. })
  302. },
  303. // 货架订单列表
  304. toOrder(){
  305. if(this.hasShelf){
  306. uni.navigateTo({
  307. url: "/pages/digitalShelf/orderList"
  308. })
  309. }else{
  310. uni.showToast({
  311. icon:'none',
  312. title: '门店没有关联数字货架,无法使用此功能!'
  313. })
  314. }
  315. },
  316. // 获取上方滚动扫描记录
  317. getScrollLog(){
  318. scanVinLogQueryRoll({pageNo:1,pageSize:1000}).then(res => {
  319. console.log(res)
  320. this.list = res.data.list || []
  321. })
  322. },
  323. // 获取当前门店扫描记录
  324. getVinLog(){
  325. this.vinList = []
  326. this.status = "loading"
  327. // VISITOR:游客,EMPLOYEE:雇员
  328. getScanVinLogList({ pageNo:1, pageSize:5, identifyType: this.userInfo.identifyType }).then(res => {
  329. this.vinList = res.data&&res.data.list || []
  330. this.vinList = this.vinList.filter(item => item.vinCode)
  331. this.status = 'nomore'
  332. })
  333. },
  334. // 查询是否支持数字货架
  335. getStoreShelf(){
  336. findStoreShelf().then(res => {
  337. console.log(res)
  338. this.$store.state.vuex_storeShelf = res.data;
  339. if(res.data){
  340. // 保证金查询
  341. this.getShelfBWPayRecord()
  342. // 获取订单信息
  343. this.shelfGetTotalWaitQty()
  344. }
  345. })
  346. },
  347. // 获取保证金金额
  348. getShelfBWPayRecord(){
  349. const data = this.$store.state.vuex_storeShelf
  350. shelfBondRecordWaitPayRecord({shelfSn: data.shelfSn, storeSn: data.storeSn}).then(res => {
  351. console.log(res,'获取保证金金额')
  352. this.bondRecord = res.data
  353. })
  354. },
  355. // 保证金支付
  356. toPayBondAmount(){},
  357. openTakeGood(){
  358. // 已有数字货架
  359. if(this.hasShelf){
  360. this.showAction = true
  361. }else{
  362. uni.showToast({
  363. icon:'none',
  364. title: '门店没有关联数字货架,无法使用此功能!'
  365. })
  366. }
  367. },
  368. // 选择取货方式
  369. clickAction(index){
  370. const shelfSn = this.hasShelf.shelfSn
  371. const _this = this
  372. // 扫描
  373. if(index == 0){
  374. uni.scanCode({
  375. success: function (ret) {
  376. console.log(ret);
  377. const params = {
  378. codeType: ret.scanType == 'QR_CODE' ? 0 : 1
  379. }
  380. // 二维码
  381. if(ret.scanType == 'QR_CODE'){
  382. const result = ret.result.split("&")
  383. params.productSn = result[2] // 产品编码sn
  384. }else{
  385. params.qrCode = ret.result
  386. }
  387. uni.showLoading({
  388. title: "正在查询产品..."
  389. })
  390. // 确认取货
  391. getProductfindByScanCode(params).then(res => {
  392. if(res.status == 200 && res.data){
  393. if(res.data.currentInven){
  394. const billSource = ret.scanType == 'QR_CODE' ? 'qr_code': 'bar_code'
  395. const params = Object.assign({shelfSn: shelfSn, billSource: billSource},res.data)
  396. _this.$store.state.vuex_tempData = params
  397. uni.navigateTo({
  398. url: '/pages/queryByCode/confirmQh'
  399. })
  400. }else{
  401. uni.showModal({
  402. title: '提示',
  403. content: '产品库存为0,无法取货!',
  404. confirmText: '好的',
  405. showCancel: false
  406. })
  407. }
  408. }else{
  409. uni.showModal({
  410. title: '提示',
  411. content: '产品不属于此货架,请重新扫描!',
  412. confirmText: '好的',
  413. showCancel: false
  414. })
  415. }
  416. uni.hideLoading()
  417. })
  418. }
  419. });
  420. }else{
  421. // 按编码搜索
  422. uni.navigateTo({
  423. url: '/pages/queryByCode/queryByCode'
  424. })
  425. }
  426. },
  427. // 去扫描
  428. openCamera(){
  429. if(this.hasLogin){
  430. if(this.userInfo.sysUserFlag == '0'){
  431. if(this.vuex_vinScanNums < this.scanMaxNums){
  432. uni.navigateTo({
  433. url: "/pages/scan-frame/scan-frame"
  434. })
  435. }else{
  436. uni.showModal({
  437. title: '提示',
  438. content: '个人用户扫描VIN仅限10次,您的次数已用完!',
  439. confirmText: '好的',
  440. showCancel: false,
  441. success(res) {}
  442. })
  443. }
  444. }else{
  445. uni.navigateTo({
  446. url: "/pages/scan-frame/scan-frame"
  447. })
  448. }
  449. }else{
  450. uni.navigateTo({
  451. url: '/pages/login/login'
  452. })
  453. }
  454. },
  455. // 查看扫描记录
  456. toAllRecord(){
  457. uni.navigateTo({
  458. url: this.hasLogin ? "/pages/vinRecord/vinRecord" : '/pages/login/login'
  459. })
  460. },
  461. toUser(){
  462. if(this.hasLogin){
  463. // 用户详细信息 或 门店认证
  464. uni.navigateTo({
  465. url: this.userInfo.sysUserFlag == '1' ? '/pages/personData/personData' : '/pages/storeManage/storeAuth'
  466. })
  467. }else{
  468. uni.navigateTo({
  469. url: '/pages/login/login'
  470. })
  471. }
  472. },
  473. toChoosePart(item){
  474. item.text = item.modelInfo
  475. uni.navigateTo({
  476. url: "/pages/digitalShelf/choosePart?vinNumber="+item.vinCode+"&carList="+encodeURIComponent(JSON.stringify(item))
  477. })
  478. }
  479. }
  480. }
  481. </script>
  482. <style lang="less">
  483. page{
  484. background-color: #ffffff;
  485. }
  486. .content {
  487. margin: 0;
  488. padding: 0;
  489. height: 100vh;
  490. display: flex;
  491. flex-direction: column;
  492. background-image: linear-gradient(#86defa 0%,#cdeff9 25%,#ffffff 40%);
  493. .header-box{
  494. z-index: 5;
  495. padding: 0em 1em;
  496. background: #066cff;
  497. .title{
  498. padding: 0;
  499. }
  500. }
  501. .cbody{
  502. flex-grow: 1;
  503. overflow-y: auto;
  504. overflow-x: hidden;
  505. }
  506. .body-box{
  507. padding: 0em 1em 0.8em;
  508. z-index: 4;
  509. .notices{
  510. padding: 0.5em 0 0;
  511. font-size: 0.9em;
  512. margin-top: 0.5rem;
  513. view{
  514. color: #ffaf46;
  515. max-width: 80%;
  516. }
  517. .text{
  518. color: #ffffff;
  519. margin-left: 1em;
  520. }
  521. }
  522. .scanButton{
  523. margin: 0.8em 0 0.5em;
  524. padding: 0.5em;
  525. background: #066cff;
  526. color: #fff;
  527. font-size: 1.5em;
  528. border-radius: 5em;
  529. justify-content: center;
  530. &:active{
  531. opacity: 0.8;
  532. }
  533. }
  534. .quickButton{
  535. margin: 0.8em 0 0.5em;
  536. padding: 0.5em;
  537. background: #fff;
  538. color: #333;
  539. font-size: 1.5em;
  540. border-radius: 5em;
  541. justify-content: center;
  542. border:0.1rpx solid #eee;
  543. box-shadow: 1rpx 2rpx 5rpx #f8f8f8;
  544. &:active{
  545. opacity: 0.8;
  546. }
  547. }
  548. .ml10{
  549. margin-left: 0.4em;
  550. }
  551. }
  552. .bg-blue{
  553. position: relative;
  554. > view{
  555. z-index: 100;
  556. position: relative;
  557. }
  558. &::after{
  559. /* 这个伪类的作用就是一个圆弧的背景色 */
  560. width: 130%;
  561. height: 100%;
  562. position: absolute;
  563. /*设置水平居中*/
  564. left: -15%;
  565. /* 之所以left:20%,是因为width:140%,若width:160%,那么left:30%才能水平居中 */
  566. top: -20%;
  567. /*层叠顺序,最底层显示*/
  568. content: '';
  569. border-radius: 0 0 50% 50%;
  570. /*分别对应 左上 右上 右下 左下 可以修改成其它颜色*/
  571. background: linear-gradient(to bottom, #066cff, #1d77ff);
  572. }
  573. .userCard{
  574. position:relative;
  575. left:0;
  576. bottom:-1rem;
  577. padding:0.8em;
  578. background: #fff;
  579. border-radius: 0.5em;
  580. box-shadow: 0.3em 0.3em 1em #c4e5ee;
  581. .userCard-info{
  582. flex-grow:1;
  583. > view{
  584. &:last-child{
  585. margin-left: 0.5em;
  586. line-height: 1.5em;
  587. .user-name{
  588. font-size: 1rem;
  589. }
  590. >view{
  591. padding: 0.2em;
  592. }
  593. }
  594. }
  595. .user-info{
  596. flex-grow:1;
  597. }
  598. }
  599. .user-rz{
  600. font-size: 0.8rem;
  601. color:#58aff5;
  602. }
  603. }
  604. }
  605. .list-box{
  606. padding: 0 1em;
  607. overflow: auto;
  608. .des{
  609. text-align: center;
  610. padding: 1em 0;
  611. color: #999;
  612. font-size: 0.8em;
  613. }
  614. }
  615. }
  616. </style>