index.vue 7.4 KB

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