index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view class="content">
  3. <view class="header-box">
  4. <view class="status_bar"></view>
  5. <view class="title"><text>管配件,就用</text>修配易码通</view>
  6. </view>
  7. <view class="body-box">
  8. <!-- 滚动区域 -->
  9. <view class="scroll-list">
  10. <scrollBox v-if="list.length" :list="list"></scrollBox>
  11. </view>
  12. <!-- 保证金 -->
  13. <view class="notices flex align_center" v-if="bondRecord" @click="toPayBondAmount">
  14. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有一笔保证金待支付 ¥{{bondRecord.bondAmount}}</view>
  15. <!-- <text>立即支付>></text> -->
  16. </view>
  17. <!-- 待取货提醒 -->
  18. <view class="notices flex align_center" v-if="!bondRecord&&orderTodo" @click="toOrder">
  19. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有待取货的货架订单哦!</view> <text>立即处理>></text>
  20. </view>
  21. <!-- 名片 -->
  22. <view class="userCard flex align_center justify_between" @click="toUser">
  23. <view class="userCard-info flex align_center justify_between">
  24. <view>
  25. <u-image v-if="!hasLogin" src="/static/def_personal_avatar.png" width="60" height="60"></u-image>
  26. <open-data v-else type="userAvatarUrl" class="user-photo"></open-data>
  27. </view>
  28. <view>
  29. <view v-if="!hasLogin" style="font-size: 40rpx;">
  30. 请点击登录
  31. </view>
  32. <view v-else>
  33. <view>{{userInfo.userNameCN}}</view>
  34. <view>{{userInfo.orgName}}</view>
  35. </view>
  36. </view>
  37. </view>
  38. <view>
  39. <u-icon name="arrow-right"></u-icon>
  40. </view>
  41. </view>
  42. <!-- 扫描按钮 -->
  43. <view class="scanButton flex align_center" @click="openCamera">
  44. <u-icon name="scan" size="40"></u-icon><text class="ml10">扫描VIN</text>
  45. </view>
  46. <!-- 扫描记录 -->
  47. <u-cell-group :border="false">
  48. <u-cell-item title="VIN查询历史" @click="toAllRecord" :title-style="{fontSize:'1.1em'}" :value="hasLogin?'查看全部':''">
  49. <u-icon slot="icon" size="38" v-if="hasLogin" color="#00aaff" style="margin-right: 0.3em;" name="order"></u-icon>
  50. </u-cell-item>
  51. </u-cell-group>
  52. </view>
  53. <!-- 扫描记录 -->
  54. <view class="list-box">
  55. <u-cell-group :border="false" v-if="hasLogin">
  56. <u-cell-item v-for="item in vinList" @click="toChoosePart(item)" :key="item.id" :title="item.vinCode" :title-style="{fontSize:'1em'}" :label="item.brandName +' '+item.modelName">
  57. <text slot="icon"></text>
  58. </u-cell-item>
  59. <view style="padding: 20upx;">
  60. <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>
  61. <u-loadmore v-if="status=='loading'" :status="status" />
  62. </view>
  63. </u-cell-group>
  64. <view class="des" v-if="vinList.length&&hasLogin">仅展示最近10条记录,点击“全部”查看更多</view>
  65. <view class="des" v-if="!hasLogin">请登录后查看历史记录</view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import {
  71. mapState,
  72. mapMutations,
  73. } from 'vuex'
  74. import scrollBox from '@/components/scrollBox.vue'
  75. import { shelfBondRecordWaitPayRecord, findStoreShelf, shelfGetTotalWaitQty } from '@/api/shelf.js'
  76. import { listLookUp, getLookUpDatas } from '@/api/data.js';
  77. import { scanVinLogQueryRoll, getScanVinLogList }from '@/api/car.js'
  78. export default {
  79. components: {
  80. scrollBox
  81. },
  82. data() {
  83. return {
  84. status: 'loading',
  85. noDataText: '暂无数据',
  86. bondRecord: null, // 保证金
  87. list:[],
  88. vinList: [],
  89. orderTodo: null,
  90. }
  91. },
  92. computed: {
  93. ...mapState(['hasLogin']),
  94. hasShelf(){
  95. return this.$store.state.vuex_storeShelf
  96. },
  97. userInfo(){
  98. return this.$store.state.vuex_userInfo
  99. }
  100. },
  101. onReady() {
  102. // 检测是否登录
  103. this.$store.dispatch('checkLogin',()=>{
  104. this.pageInit()
  105. })
  106. this.getScrollLog()
  107. },
  108. onLoad() {
  109. // 获取数据字典
  110. this.getListLookUp();
  111. // 获取支付,收款方式
  112. this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
  113. // 刷新首页数据
  114. uni.$on("refashHome",()=>{
  115. this.pageInit()
  116. })
  117. },
  118. onUnload() {
  119. uni.$off('refashHome')
  120. },
  121. // 下拉刷新
  122. onPullDownRefresh(){
  123. this.pageInit()
  124. setTimeout(function () {
  125. uni.stopPullDownRefresh();
  126. }, 1000);
  127. },
  128. onShareAppMessage() {
  129. },
  130. methods: {
  131. pageInit(){
  132. if(this.hasLogin){
  133. // 查询是否有数字货架
  134. this.getStoreShelf()
  135. // 获取扫描记录
  136. this.getVinLog()
  137. }
  138. },
  139. // 获取数据字典
  140. getListLookUp() {
  141. const _this = this;
  142. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  143. if (res.status == 200) {
  144. _this.$store.state.vuex_allLookUp = res.data;
  145. }
  146. });
  147. },
  148. // 或某一项字典列表,参数code
  149. getLookUpList(code, vuexKey) {
  150. getLookUpDatas({ type: code }).then(res => {
  151. if (res.status == 200) {
  152. this.$store.state[vuexKey] = res.data || [];
  153. }
  154. });
  155. },
  156. // 待取货数量合计
  157. shelfGetTotalWaitQty(){
  158. shelfGetTotalWaitQty({billState:'WAIT'}).then(res => {
  159. if(res.status == 200){
  160. this.orderTodo = res.data
  161. }
  162. })
  163. },
  164. // 货架订单列表
  165. toOrder(){
  166. if(this.hasShelf){
  167. uni.navigateTo({
  168. url: "/pages/digitalShelf/orderList"
  169. })
  170. }else{
  171. uni.showToast({
  172. icon:'none',
  173. title: '门店没有关联数字货架,无法使用此功能!'
  174. })
  175. }
  176. },
  177. getScrollLog(){
  178. scanVinLogQueryRoll({pageNo:1,pageSize:1000}).then(res => {
  179. this.list = res.data.list || []
  180. })
  181. },
  182. getVinLog(){
  183. this.vinList = []
  184. this.status = "loading"
  185. getScanVinLogList({pageNo:1,pageSize:10}).then(res => {
  186. this.vinList = res.data.list || []
  187. this.vinList = this.vinList.filter(item => item.vinCode)
  188. this.status = 'nomore'
  189. })
  190. },
  191. // 查询是否支持数字货架
  192. getStoreShelf(){
  193. findStoreShelf().then(res => {
  194. console.log(res)
  195. this.$store.state.vuex_storeShelf = res.data;
  196. if(res.data){
  197. // 保证金查询
  198. this.getShelfBWPayRecord()
  199. // 获取订单信息
  200. this.shelfGetTotalWaitQty()
  201. }
  202. })
  203. },
  204. // 获取保证金金额
  205. getShelfBWPayRecord(){
  206. const data = this.$store.state.vuex_storeShelf
  207. shelfBondRecordWaitPayRecord({shelfSn: data.shelfSn, storeSn: data.storeSn}).then(res => {
  208. console.log(res,'获取保证金金额')
  209. this.bondRecord = res.data
  210. })
  211. },
  212. // 保证金支付
  213. toPayBondAmount(){
  214. },
  215. // 去扫描
  216. openCamera(){
  217. uni.navigateTo({
  218. url: this.hasLogin ? "/pages/scan-frame/scan-frame" : '/pages/login/login'
  219. })
  220. },
  221. // 查看扫描记录
  222. toAllRecord(){
  223. uni.navigateTo({
  224. url: this.hasLogin ? "/pages/vinRecord/vinRecord" : '/pages/login/login'
  225. })
  226. },
  227. toUser(){
  228. uni.navigateTo({
  229. url: this.hasLogin ? '/pages/personData/personData' : '/pages/login/login'
  230. })
  231. },
  232. toChoosePart(item){
  233. if(this.hasShelf){
  234. item.text = item.modelInfo
  235. uni.navigateTo({
  236. url: "/pages/digitalShelf/choosePart?vinNumber="+item.vinCode+"&carList="+encodeURIComponent(JSON.stringify(item))
  237. })
  238. }else{
  239. uni.showToast({
  240. icon:'none',
  241. title: '门店没有关联数字货架,无法使用此功能!'
  242. })
  243. }
  244. }
  245. }
  246. }
  247. </script>
  248. <style lang="less">
  249. .content {
  250. margin: 0;
  251. padding: 0;
  252. height: 100vh;
  253. display: flex;
  254. flex-direction: column;
  255. background-image: linear-gradient(#86defa 0%,#cdeff9 25%,#ffffff 40%);
  256. .header-box{
  257. padding: 0.3em 1em;
  258. .status_bar {
  259. height: var(--status-bar-height);
  260. width: 100%;
  261. }
  262. .title{
  263. padding-top: 0.4em;
  264. font-size: 1.5em;
  265. color: #000;
  266. text{
  267. color: #0077fd;
  268. }
  269. }
  270. }
  271. .body-box{
  272. padding: 0.5em 1em;
  273. .notices{
  274. padding: 0.5em 0 0;
  275. view{
  276. color: #f2a557;
  277. }
  278. text{
  279. color: #0077fd;
  280. margin-left: 1em;
  281. }
  282. }
  283. .userCard{
  284. margin-top: 0.8em;
  285. padding:0.8em;
  286. background: #fff;
  287. border-radius: 1em;
  288. box-shadow: 0.2em 0.3em 0.8em #cdeff9;
  289. .userCard-info{
  290. > view{
  291. &:last-child{
  292. margin-left: 0.5em;
  293. >view{
  294. padding: 0.2em;
  295. }
  296. }
  297. }
  298. }
  299. .user-photo{
  300. display: block;
  301. width: 120rpx;
  302. height: 120rpx;
  303. border-radius: 50%;
  304. overflow: hidden;
  305. }
  306. }
  307. .scanButton{
  308. margin: 0.6em 0;
  309. padding: 0.5em;
  310. background: #1283d4;
  311. color: #fff;
  312. font-size: 1.5em;
  313. border-radius: 5em;
  314. justify-content: center;
  315. &:active{
  316. opacity: 0.8;
  317. }
  318. }
  319. .ml10{
  320. margin-left: 0.2em;
  321. }
  322. }
  323. .list-box{
  324. flex-grow: 1;
  325. padding: 0 1em;
  326. overflow: auto;
  327. .des{
  328. text-align: center;
  329. padding: 1em 0;
  330. color: #999;
  331. font-size: 0.8em;
  332. }
  333. }
  334. }
  335. </style>