index.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  1. <template>
  2. <view>
  3. <view class="content" :class="hasShopiing?'bg-0':'bg-0'">
  4. <!-- 头部栏 -->
  5. <view class="header-box">
  6. <UniStatusBar></UniStatusBar>
  7. <view class="title flex align_center" :style="{height:(navHeight+'px')}">
  8. <u-image src="/static/logo-h.png" width="349" height='40'></u-image>
  9. <!-- 版本提示 -->
  10. <text class="version" v-if="showVersion">体验版</text>
  11. </view>
  12. </view>
  13. <view class="cbody">
  14. <view :class="hasShopiing?'shopping bg-blue':'body-box bg-blue'">
  15. <!-- 滚动区域 -->
  16. <view class="scroll-list" v-if="!hasShopiing">
  17. <scrollBox v-if="list.length&&!hasRedPacket" :list="list"></scrollBox>
  18. <scrollBox v-if="slist.length&&hasRedPacket" :list="slist"></scrollBox>
  19. </view>
  20. <!-- 保证金 -->
  21. <view class="notices flex align_center" v-if="bondRecord" @click="toPayBondAmount">
  22. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有一笔保证金待支付 ¥{{bondRecord.bondAmount}}</view>
  23. <!-- <text class="text">立即支付>></text> -->
  24. </view>
  25. <!-- 待取货提醒 -->
  26. <view class="notices flex align_center" v-if="!bondRecord&&orderTodo" @click="toOrder">
  27. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有待取货的货架订单哦!</view> <text class="text">立即处理>></text>
  28. </view>
  29. <!-- 门店审核不通过 -->
  30. <view class="notices flex justify_between" v-if="storeApply&&storeApply.auditStatus=='REFUSE'&&storeApply.readFlag=='0'">
  31. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 门店认证资料审核不通过,请重新提交审核!</view> <text class="text" @click="toKnow">知道了</text>
  32. </view>
  33. <!-- 名片 -->
  34. <view class="userCard flex align_center justify_between" v-if="!hasShopiing">
  35. <view class="userCard-info flex align_center">
  36. <view>
  37. <u-image shape='circle' v-if="!hasLogin" src="/static/def_personal_avatar.png" width="90" height="90"></u-image>
  38. <u-image shape='circle' v-else :src="avatarUrl||'/static/def_personal_avatar.png'" width="90" height="90"></u-image>
  39. </view>
  40. <view class="user-info" @click="toUser">
  41. <view v-if="!hasLogin" style="font-size: 40rpx;">
  42. 请点击登录
  43. </view>
  44. <view v-else>
  45. <view class="user-name">{{userInfo.userNameCN || userInfo.mobile}}</view>
  46. <view v-if="hasLogin&&userInfo&&userInfo.sysUserFlag == '0'">
  47. <u-tag text="个人用户" mode="dark" type="warning" shape="circle" size="mini" />
  48. </view>
  49. <view v-else>{{userInfo.orgName}}</view>
  50. </view>
  51. </view>
  52. </view>
  53. <view @click="toUser">
  54. <text v-if="hasLogin&&userInfo&&userInfo.sysUserFlag == '0'" class="user-rz">
  55. {{storeApply&&storeApply.auditStatus=='WAIT'?'认证门店审核中':'认证成为门店'}}
  56. </text>
  57. <uni-icons type="arrowright" size="20" color="#999"></uni-icons>
  58. </view>
  59. </view>
  60. <!-- 搜索 -->
  61. <view class="search-head" v-if="hasShopiing" @click="toSearch">
  62. <uni-search-bar readonly radius="100" placeholder="请输入商品名称/产品编码/原厂编码" clearButton="auto" cancelButton="none"/>
  63. </view>
  64. </view>
  65. <view :class="hasShopiing?'body-box1':'body-box'">
  66. <!-- 扫描按钮 -->
  67. <view class="action-button flex" v-if="userInfo.sysUserFlag == '1'&&!hasShopiing">
  68. <view class="f1" @click="openTakeGood(1)">
  69. <view class="icons"><u-icon name="bianmachaxun" custom-prefix="custom-icon"></u-icon></view>
  70. <view class="tits">产品编码取货</view>
  71. </view>
  72. <view class="f2" @click="openTakeGood(0)">
  73. <view class="icons"><u-icon name="saoma" custom-prefix="custom-icon"></u-icon></view>
  74. <view class="tits">二维码/条形码取货</view>
  75. </view>
  76. </view>
  77. <!-- banner -->
  78. <view class="banner">
  79. <u-swiper mode="dot" bg-color="" img-mode="widthFix" @click="clickBanner" :interval="3000" :height="hasShopiing?280:374" :list="imgList"></u-swiper>
  80. </view>
  81. <!-- 快捷导航 -->
  82. <view class="quick-nav pa-box" v-if="hasShopiing&&navList.length">
  83. <iconItemsList :list="navList" :iconSize="45" @callback="onNavFun"></iconItemsList>
  84. </view>
  85. <!-- 产品分类 -->
  86. <view class="ptype-nav pa-box" v-if="hasShopiing&&productTypeList.length">
  87. <swiper class="swiper" @change="e=>{currentPtypeDot=e.detail.current}">
  88. <swiper-item v-for="(item, idx) in productTypeList" :index="idx" :key="item.id">
  89. <iconItemsList :list="item.list" type="img"></iconItemsList>
  90. </swiper-item>
  91. </swiper>
  92. <view class="indicator-dots">
  93. <view v-for="(item,idx) in productTypeList" :key="idx" :class="currentPtypeDot==idx?'indicator-dots-active':''" ></view>
  94. </view>
  95. </view>
  96. <!-- 产品列表 -->
  97. <view class="product-box" v-if="hasShopiing && productList.length">
  98. <u-divider bg-color="">热门推荐</u-divider>
  99. <view class="product-list">
  100. <!-- 产品列表 -->
  101. <productItem
  102. v-for="(item,index) in productList"
  103. :key="index"
  104. :list="item"
  105. :index="index"
  106. :itemWidth="(screenWidth-25)*0.5"
  107. :gap="5"
  108. :isLogin="hasLogin"
  109. ></productItem>
  110. <view style="padding: 20upx;">
  111. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="productList.length==0 && status!='loading'" mode="list"></u-empty>
  112. <u-loadmore v-if="status=='loading'" :status="status" />
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 扫描记录 -->
  118. <view class="list-box" v-if="!hasShopiing">
  119. <!-- 扫描记录 -->
  120. <u-cell-group :border="false">
  121. <u-cell-item title="VIN查询历史" @click="toAllRecord" :title-style="{fontSize:'1em'}" value="全部">
  122. <u-icon slot="icon" size="32" color="#066cff" style="margin-right: 0.3em;" name="order"></u-icon>
  123. </u-cell-item>
  124. </u-cell-group>
  125. <u-cell-group :border="false" v-if="hasLogin">
  126. <u-cell-item v-for="item in vinList"
  127. @click="toChoosePart(item)"
  128. :key="item.id"
  129. :title="item.vinCode"
  130. :title-style="{fontSize:'1em'}"
  131. :label="userInfo&&userInfo.sysUserFlag == '0' ? item.createDate : (item.brandName +' '+item.modelName)">
  132. <text slot="icon"></text>
  133. </u-cell-item>
  134. <view style="padding: 20upx;">
  135. <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>
  136. <u-loadmore v-if="status=='loading'" :status="status" />
  137. </view>
  138. </u-cell-group>
  139. <view class="des" v-if="vinList.length&&hasLogin">仅展示最近5条记录,点击“全部”查看更多</view>
  140. <view class="des" v-if="!hasLogin">请登录后查看历史记录</view>
  141. </view>
  142. </view>
  143. </view>
  144. <!-- tab栏 -->
  145. <u-tabbar :list="vuex_tabBarList" :mid-button-size="80" :before-switch="beforeSwitch" :midButton="vuex_tabBarList.length==5"></u-tabbar>
  146. </view>
  147. </template>
  148. <script>
  149. import {
  150. mapState,
  151. mapMutations,
  152. } from 'vuex'
  153. import scrollBox from '@/components/scrollBox.vue'
  154. import UniStatusBar from '@/components/uni-status-bar/uni-status-bar.vue'
  155. import iconItemsList from '@/components/icon-items-list/icon-items-list.vue'
  156. import productItem from './productItem.vue'
  157. import { shelfBondRecordWaitPayRecord, findStoreShelf, shelfGetTotalWaitQty, getProductfindByScanCode, queryQplsConfig } from '@/api/shelf.js'
  158. import { xprhStoreApplyRead } from '@/api/xprh.js'
  159. import { findCurrentRewardRule } from '@/api/rewardRule.js'
  160. import { listLookUp, getLookUpDatas, getCurrUserInfo } from '@/api/data.js';
  161. import { scanVinLogQueryRoll, getScanVinLogList, getScanGetMaxQty }from '@/api/car.js'
  162. import { promoTerminalList } from '@/api/video.js'
  163. import { getRewardRollList } from '@/api/rewardRule.js'
  164. import { getShopStatus } from '@/api/cart.js'
  165. import { getShopCategory, getShopProductList } from '@/api/shop.js'
  166. import { openWebView } from "@/utils/index.js"
  167. export default {
  168. components: {
  169. iconItemsList, // 图标网格
  170. scrollBox, // 无缝滚动组件
  171. UniStatusBar, // 状态栏组件
  172. productItem // 产品列表
  173. },
  174. data() {
  175. const _this = this
  176. return {
  177. status: 'loading',
  178. noDataText: '暂无数据',
  179. hasShopiing: true, // 是否开通商城
  180. bondRecord: null, // 保证金
  181. list:[], // 扫描记录滚动
  182. slist:[], // 红包滚动
  183. vinList: [], // 扫描记录
  184. orderTodo: null, // 待取货的货架订单信息
  185. avatarUrl:'', // 用户图像
  186. navHeight: '44', // 头部高度
  187. scanMaxNums: 10, // 扫描VIN仅限10次
  188. carouselList: [] ,// 修理厂促销活动列表
  189. productTypeList: [], // 产品分类
  190. currentPtypeDot: 0, // 当前产品分类页
  191. screenWidth: 325, // 屏幕宽度
  192. productList:[], // 热门产品
  193. hotProductPageNo: 1 // 热门产品页码
  194. }
  195. },
  196. computed: {
  197. ...mapState(['hasLogin','vuex_vinScanNums','vuex_tabBarList']),
  198. // 显示开发版本信息
  199. showVersion () {
  200. const baseUrl = getApp().globalData.baseUrl
  201. return baseUrl.indexOf(".test.") >= 0
  202. },
  203. // 是否有数字货架
  204. hasShelf(){
  205. return this.$store.state.vuex_storeShelf
  206. },
  207. // 登录用户信息
  208. userInfo(){
  209. return this.$store.state.vuex_userInfo
  210. },
  211. // 是否有门店申请信息
  212. storeApply(){
  213. return this.$store.state.vuex_storeAuthInfo || null
  214. },
  215. // 是否有红包
  216. hasRedPacket(){
  217. const rule = this.$store.state.vuex_rewardRule
  218. return rule&&rule.ruleStatus == 'release'
  219. },
  220. // banner 图片列表
  221. imgList(){
  222. let list = [
  223. {
  224. image: this.hasShopiing ? '/static/banner1.jpg':'/static/banner1.png',
  225. activeType: ''
  226. }
  227. ]
  228. // 红包
  229. if(this.hasRedPacket&&this.hasShelf){
  230. list.push(
  231. {
  232. image: this.hasShopiing ? '/static/banner2.jpg':'/static/banner2.png',
  233. activeType: 'redPacket'
  234. })
  235. }
  236. return list.concat(this.carouselList)
  237. },
  238. // 快捷导航
  239. navList(){
  240. const list = [
  241. {
  242. id:'n0',
  243. auth: true,
  244. icon:'bianmachaxun',
  245. name: '产品编码取货',
  246. color:'#056cd9',
  247. url: 'openTakeGood0',
  248. target: 'fun'
  249. },
  250. {
  251. id:'n1',
  252. auth: true,
  253. icon:'saoma',
  254. name: '二维/条码取货',
  255. color:'#ffaa7f',
  256. url:'openTakeGood1',
  257. target: 'fun'
  258. },
  259. {
  260. id:'n3',
  261. auth: true,
  262. icon:'shipin1',
  263. name: '视频教程',
  264. color:'#55aaff',
  265. url:'/pagesB/videos/index',
  266. target: 'page'
  267. },
  268. {
  269. id:'n2',
  270. auth: true,
  271. icon:'chaxunjilu',
  272. name: 'VIN查询历史',
  273. color:'#97d695',
  274. url:'/pagesA/vinRecord/vinRecord',
  275. target: 'page'
  276. }
  277. ]
  278. return list
  279. }
  280. },
  281. onReady() {
  282. // 获取导航栏高度
  283. const res = uni.getSystemInfoSync()
  284. this.screenWidth = res.windowWidth
  285. const system = res.platform
  286. if (system === 'android') {
  287. this.navHeight = 48
  288. } else if (system === 'ios') {
  289. this.navHeight = 44
  290. }
  291. },
  292. onLoad() {
  293. this.orderTodo = null
  294. this.bondRecord = null
  295. this.vinList = []
  296. // 视频类型
  297. this.getLookUpList('CONTENT_CATEGORY', 'vuex_videoTypeList');
  298. // 检测是否登录
  299. this.$store.dispatch('checkLogin',()=>{
  300. // 获取数据字典
  301. this.getListLookUp();
  302. // 获取支付,收款方式
  303. this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
  304. // 价格类型
  305. this.getLookUpList('PRICE_SHOW_TYPE', 'vuex_priceTypeList');
  306. // 初始化页面
  307. this.pageInit(false)
  308. })
  309. // 刷新首页数据
  310. uni.$on("refashHome",()=>{
  311. this.pageInit(true)
  312. })
  313. // 商品分类
  314. this.getGoodType()
  315. },
  316. // 页面卸载
  317. onUnload() {
  318. uni.$off('refashHome')
  319. uni.$off('refashProm')
  320. },
  321. // 下拉刷新
  322. onPullDownRefresh(){
  323. this.pageInit(true)
  324. setTimeout(function () {
  325. uni.stopPullDownRefresh();
  326. }, 1000);
  327. },
  328. onShareAppMessage() {},
  329. onShow() {
  330. // 用户头像
  331. this.avatarUrl = uni.getStorageSync('userPhoto');
  332. if(this.hasLogin){
  333. // 查询门店认证信息
  334. if(this.userInfo.sysUserFlag == '0'){
  335. this.findLastApply()
  336. }
  337. if(this.userInfo.sysUserFlag == '1'){
  338. // 查询红包活动
  339. this.getRedPacketRule()
  340. }
  341. // 重新刷新
  342. this.pageInit(true)
  343. }else{
  344. // 隐藏促销模块
  345. this.hidePromoTab()
  346. // 滚动扫描记录
  347. this.getScrollLog()
  348. }
  349. },
  350. methods: {
  351. // 扫描vin
  352. beforeSwitch(index){
  353. const row = this.$store.state.vuex_tabBarList[index]
  354. if(row.text == '促销'){
  355. uni.$emit('refashProm')
  356. }
  357. if(row.text == '购物车'){
  358. uni.navigateTo({
  359. url:'/pagesB/cart/index',
  360. target: 'page'
  361. })
  362. }
  363. if(row.text == '扫描VIN'){
  364. this.openCamera()
  365. }else{
  366. return true
  367. }
  368. },
  369. // 去搜索产品
  370. toSearch(event){
  371. uni.navigateTo({
  372. url:'/pagesB/shopiing/searchProduct?queryWord='+event.value+'&clzId='
  373. })
  374. },
  375. // 初始化页面
  376. pageInit(flag){
  377. this.carouselList = []
  378. if(this.hasLogin){
  379. // 非游客
  380. if(this.userInfo.sysUserFlag == '1'){
  381. // 查询是否有商城
  382. this.getHasShopping(flag)
  383. }else{// 游客
  384. // 获取扫描次数
  385. this.$store.dispatch("getScanNums")
  386. // 获取最大扫描次数
  387. this.getMaxQty()
  388. // 查询门店认证信息
  389. this.findLastApply()
  390. // 获取扫描记录
  391. this.getVinLog()
  392. // 商品分类
  393. this.getGoodType()
  394. }
  395. }else{
  396. uni.removeStorageSync('token')
  397. }
  398. },
  399. // 轮播图片
  400. getCarousel(){
  401. this.carouselList = []
  402. // 获取所有促销活动数据
  403. promoTerminalList({}).then(res => {
  404. if(res.status == 200){
  405. res.data&&res.data.map(item => {
  406. item.image = item.imageSet&&item.imageSet[0] // 默认取第一张图片
  407. })
  408. // 过滤掉产品促销活动
  409. // this.carouselList = res.data.filter(item => item.content.indexOf("pages/promo/index") < 0)
  410. // 所有数据
  411. this.carouselList = res.data
  412. }
  413. })
  414. },
  415. // 快速导航单击
  416. onNavFun(item){
  417. if(this.hasLogin){
  418. // 非游客
  419. if(this.userInfo.sysUserFlag == '1'){
  420. // 编码取货
  421. if(item.url=='openTakeGood1'){
  422. this.openTakeGood(1)
  423. }
  424. // 扫码取货
  425. if(item.url=='openTakeGood0'){
  426. this.openTakeGood(0)
  427. }
  428. }else{
  429. uni.showModal({
  430. title: '提示',
  431. content: '你还未申请认证门店,暂无法使用此功能',
  432. confirmText: '去认证',
  433. success(res) {
  434. if(res.confirm){
  435. uni.navigateTo({
  436. url: '/pages/storeManage/storeAuth'
  437. })
  438. }
  439. }
  440. })
  441. }
  442. }else{
  443. uni.navigateTo({
  444. url: '/pages/login/login'
  445. })
  446. }
  447. },
  448. // 获取数据字典
  449. getListLookUp() {
  450. const _this = this;
  451. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  452. if (res.status == 200) {
  453. _this.$store.state.vuex_allLookUp = res.data;
  454. }
  455. });
  456. },
  457. // 或某一项字典列表,参数code
  458. getLookUpList(code, vuexKey) {
  459. getLookUpDatas({ type: code }).then(res => {
  460. if (res.status == 200) {
  461. this.$store.state[vuexKey] = res.data || [];
  462. }
  463. });
  464. },
  465. // 获取价格配置
  466. getPriceCofig(){
  467. const data = this.$store.state.vuex_storeShelf
  468. queryQplsConfig({shelfSn: data.shelfSn}).then(res => {
  469. this.$store.state.vuex_configPrice = res.data || null
  470. })
  471. },
  472. // 最新用户信息
  473. getCurrUserInfo(){
  474. getCurrUserInfo().then(res => {
  475. if(res.data){
  476. this.$store.state.vuex_userInfo.userNameCN = res.data.name;
  477. this.$store.state.vuex_userInfo.mobile = res.data.mobile;
  478. this.$store.state.vuex_userInfo.adminId = res.data.id;
  479. this.$store.state.vuex_userPhoto = res.data.photo;
  480. uni.setStorageSync('userPhoto', res.data.photo);
  481. }
  482. })
  483. },
  484. // 获取最大扫描数
  485. getMaxQty(){
  486. getScanGetMaxQty().then(res => {
  487. this.scanMaxNums = res.data || 10
  488. this.$store.state.vuex_scanMaxNums = this.scanMaxNums
  489. })
  490. },
  491. // 获取最新申请门店
  492. findLastApply(){
  493. const mobile = this.userInfo.mobile
  494. this.$store.dispatch('getSotreAuth',mobile)
  495. },
  496. // 知道审核不通过
  497. toKnow(){
  498. uni.showLoading({
  499. title: "正在提交"
  500. })
  501. xprhStoreApplyRead({sn:this.storeApply.applySn}).then(res => {
  502. if(res.status == 200){
  503. this.findLastApply()
  504. }
  505. uni.hideLoading()
  506. })
  507. },
  508. // 待取货数量合计
  509. shelfGetTotalWaitQty(){
  510. shelfGetTotalWaitQty({billState:'WAIT'}).then(res => {
  511. if(res.status == 200){
  512. this.orderTodo = res.data;
  513. }
  514. })
  515. },
  516. // 货架订单列表
  517. toOrder(){
  518. if(this.hasShelf){
  519. uni.navigateTo({
  520. url: "/pagesA/digitalShelf/orderList"
  521. })
  522. }else{
  523. uni.showToast({
  524. icon:'none',
  525. title: '门店没有关联数字货架,无法使用此功能!'
  526. })
  527. }
  528. },
  529. // 获取上方滚动扫描记录
  530. getScrollLog(){
  531. scanVinLogQueryRoll({pageNo:1,pageSize:50}).then(res => {
  532. this.list = res.data.list || []
  533. this.list.map(item => {
  534. item.placeText = item.userName + '刚刚扫描了一个VIN'
  535. })
  536. })
  537. },
  538. // 获取当前门店扫描记录
  539. getVinLog(){
  540. this.vinList = []
  541. this.status = "loading"
  542. // VISITOR:游客,EMPLOYEE:雇员
  543. getScanVinLogList({ pageNo:1, pageSize:5, identifyType: this.userInfo.identifyType }).then(res => {
  544. this.vinList = res.data&&res.data.list || []
  545. this.vinList = this.vinList.filter(item => item.vinCode)
  546. this.status = 'nomore'
  547. })
  548. },
  549. // 商品一级分类
  550. getGoodType(){
  551. this.productTypeList = []
  552. getShopCategory({categoryLevel: 1}).then(res => {
  553. const list = res.data || []
  554. const ret = []
  555. list.forEach(item => {
  556. ret.push({
  557. id: item.id,
  558. categorySn: item.categorySn,
  559. auth: true,
  560. name: item.categoryName,
  561. icon: item.iconUrl,
  562. url: '/pagesB/shopiing/searchProduct?clzId='+item.categorySn+'&clzName='+item.categoryName,
  563. target: 'page'
  564. })
  565. })
  566. // 转成二维数组
  567. for(let i=0;i<ret.length;i=i+8){
  568. this.productTypeList.push({
  569. id: 'swiper-item-'+i,
  570. list: ret.slice(i,(i+8)>ret.length?ret.length:(i+8))
  571. })
  572. }
  573. })
  574. // 获取推荐产品
  575. this.getProductList()
  576. },
  577. // 商品列表查询
  578. getProductList(){
  579. this.productList = []
  580. this.status = "loading"
  581. getShopProductList({pageNo:this.hotProductPageNo,pageSize:15,hotFlag:1}).then(res => {
  582. if(res.status == 200){
  583. const list = res.data ? res.data.list : []
  584. this.productList.push(list)
  585. this.status = res.data.count>=this.list.length ? "nomore" : 'loadmore'
  586. // 判断是否最后一页
  587. const maxPages = Math.ceil(res.data.count / 15)
  588. this.status = this.hotProductPageNo >= maxPages ? "nomore" : 'loadmore'
  589. this.noDataText = this.status == 'nomore' ? '没有更多了' : '更多商品'
  590. }else{
  591. this.status = "nomore"
  592. this.noDataText = res.message || '没有更多了'
  593. }
  594. })
  595. },
  596. // 商城信息, flag: true 再次刷新,false 首次加载
  597. getHasShopping(flag){
  598. if(!flag){
  599. uni.showLoading({
  600. title: '加载中'
  601. })
  602. getShopStatus().then(res => {
  603. this.hasShopiing = res.data && res.data.paramValue == 1
  604. // 有商城
  605. if(this.hasShopiing){
  606. // 隐藏tab 视频,显示购物车tab
  607. this.showCatTab()
  608. // 商品分类
  609. this.getGoodType()
  610. }else{ // 没有商城
  611. // 滚动扫描记录
  612. this.getScrollLog()
  613. // 获取扫描记录
  614. this.getVinLog()
  615. }
  616. // 查询是否有数字货架
  617. this.getStoreShelf(flag)
  618. uni.hideLoading()
  619. })
  620. }else{
  621. if(!this.hasShopiing){
  622. // 滚动扫描记录
  623. this.getScrollLog()
  624. // 获取扫描记录
  625. this.getVinLog()
  626. }
  627. // 查询是否有数字货架
  628. this.getStoreShelf(flag)
  629. }
  630. },
  631. // 显示购物车tab
  632. showCatTab(){
  633. const videoIndex = this.$store.state.vuex_tabBarList.findIndex(item => item.text == '视频')
  634. const catIndex = this.$store.state.vuex_tabBarList.findIndex(item => item.text == '购物车')
  635. if(catIndex<0 && videoIndex >= 0){
  636. // 替换视频为购物车
  637. this.$store.state.vuex_tabBarList.splice(videoIndex,1,{
  638. "pagePath": "/pages/cart/index",
  639. "iconPath": "/static/tab/tab_cart_normal.png",
  640. "selectedIconPath": "/static/tab/tab_cart_pressed.png",
  641. "text": "购物车",
  642. 'customIcon': false,
  643. })
  644. }
  645. },
  646. // 查询是否支持数字货架, flag: true 再次刷新,false 首次加载
  647. getStoreShelf(flag){
  648. findStoreShelf().then(res => {
  649. this.$store.state.vuex_storeShelf = res.data;
  650. if(res.data){
  651. if(!flag){
  652. // 更新用户信息
  653. this.getCurrUserInfo()
  654. // 显示促销模块
  655. this.showPromoTab()
  656. // 保证金查询
  657. this.getShelfBWPayRecord()
  658. // 获取订单信息
  659. this.shelfGetTotalWaitQty()
  660. }
  661. // 获取价格权限配置
  662. this.getPriceCofig()
  663. // 获取轮播数据,包括促销活动
  664. this.getCarousel()
  665. }else{
  666. // 没有数字货架,隐藏促销模块
  667. this.hidePromoTab()
  668. }
  669. })
  670. },
  671. // 显示促销模块
  672. showPromoTab(){
  673. // 添加促销模块
  674. const promoIndex = this.$store.state.vuex_tabBarList.findIndex(item => item.text == '促销')
  675. if(promoIndex<0){
  676. this.$store.state.vuex_tabBarList.splice(1,0,{
  677. "pagePath": "/pages/promo/index",
  678. "iconPath": "/static/tab/tab_promo_normal.png",
  679. "selectedIconPath": "/static/tab/tab_promo_pressed.png",
  680. "text": "促销",
  681. 'customIcon': false,
  682. })
  683. }
  684. // 居中透出显示扫描按钮
  685. const scanTab = this.$store.state.vuex_tabBarList.find(item => item.text == '扫描VIN')
  686. if(scanTab){
  687. scanTab.iconPath = "/static/tab/tab_scan_mid.png"
  688. scanTab.midButton = true
  689. }
  690. },
  691. // 隐藏促销模块
  692. hidePromoTab(){
  693. // 删除促销模块
  694. const promoIndex = this.$store.state.vuex_tabBarList.findIndex(item => item.text == '促销')
  695. if(promoIndex > -1){
  696. this.$store.state.vuex_tabBarList.splice(promoIndex,1)
  697. }
  698. // 扫描按钮不局中
  699. const scanTab = this.$store.state.vuex_tabBarList.find(item => item.text == '扫描VIN')
  700. if(scanTab){
  701. scanTab.iconPath = "/static/tab/tab_scan_normal.png"
  702. scanTab.midButton = false
  703. }
  704. },
  705. // 查询是有红包活动
  706. getRedPacketRule(){
  707. findCurrentRewardRule().then(res => {
  708. this.$store.state.vuex_rewardRule = res.data;
  709. this.getRedScroll()
  710. })
  711. },
  712. // 红包奖励信息
  713. getRedScroll(){
  714. getRewardRollList({pageNo:1,pageSize:50}).then(res => {
  715. this.slist = res.data || []
  716. this.slist.map(item => {
  717. item.placeText = item.userName + '刚刚得到了'+item.totalRewardAmount+'元 红包奖励'
  718. })
  719. })
  720. },
  721. // 获取保证金金额
  722. getShelfBWPayRecord(){
  723. const data = this.$store.state.vuex_storeShelf
  724. shelfBondRecordWaitPayRecord({shelfSn: data.shelfSn, storeSn: data.storeSn}).then(res => {
  725. console.log(res,'获取保证金金额')
  726. this.bondRecord = res.data
  727. })
  728. },
  729. // 保证金支付
  730. toPayBondAmount(){},
  731. openTakeGood(index){
  732. // 已有数字货架
  733. if(this.hasShelf){
  734. this.clickAction(index)
  735. }else{
  736. uni.showToast({
  737. icon:'none',
  738. title: '门店没有关联数字货架,无法使用此功能!'
  739. })
  740. }
  741. },
  742. // 单击banner
  743. clickBanner(index){
  744. const row = this.imgList[index]
  745. // 红包
  746. if(row.activeType == 'redPacket'){
  747. uni.navigateTo({url:"/pages/morePage/redPacket"})
  748. }
  749. // 图文
  750. if(row.contentType == 'IMAGE_CONTENT'){
  751. uni.navigateTo({url:"/pagesA/activeDetail/index?sn="+row.promoActiveSn})
  752. }
  753. // 视频
  754. if(row.contentType == 'VIDEO'){
  755. uni.navigateTo({url:"/pages/videos/detail?form=banner&&sn="+row.promoActiveSn})
  756. }
  757. // 链接
  758. if(row.contentType == 'LINK'){
  759. // 货架促销活动
  760. if(row.content.indexOf("pagesB/promoDetail") >= 0){
  761. uni.navigateTo({
  762. url: '/pagesB/promoProduct?promoActiveSn='+row.promoActiveSn+'&title='+row.title
  763. })
  764. }else{
  765. openWebView({url:row.content})
  766. }
  767. }
  768. },
  769. // 选择取货方式
  770. clickAction(index){
  771. const shelfSn = this.hasShelf.shelfSn
  772. const _this = this
  773. // 扫描
  774. if(index == 0){
  775. uni.scanCode({
  776. success: function (ret) {
  777. console.log(ret);
  778. const params = {
  779. codeType: ret.scanType == 'QR_CODE' ? 0 : 1
  780. }
  781. // 二维码
  782. if(ret.scanType == 'QR_CODE'){
  783. const result = ret.result.split("&")
  784. params.productSn = result[2] // 产品编码sn
  785. }else{
  786. params.qrCode = ret.result
  787. }
  788. uni.showLoading({
  789. title: "正在查询产品..."
  790. })
  791. // 确认取货
  792. getProductfindByScanCode(params).then(res => {
  793. if(res.status == 200 && res.data){
  794. if(res.data.currentInven){
  795. const billSource = ret.scanType == 'QR_CODE' ? 'qr_code': 'bar_code'
  796. const retData = Object.assign({shelfSn: shelfSn, billSource: billSource},res.data)
  797. _this.$store.state.vuex_tempData = retData
  798. uni.navigateTo({
  799. url: '/pagesA/queryByCode/confirmQh'
  800. })
  801. }else{
  802. uni.showModal({
  803. title: '提示',
  804. content: '产品库存为0,无法取货!',
  805. confirmText: '好的',
  806. showCancel: false
  807. })
  808. }
  809. }else{
  810. uni.showModal({
  811. title: '提示',
  812. content: '产品不属于此货架,请重新扫描!',
  813. confirmText: '好的',
  814. showCancel: false
  815. })
  816. }
  817. uni.hideLoading()
  818. })
  819. }
  820. });
  821. }else{
  822. // 按编码搜索
  823. uni.navigateTo({
  824. url: '/pagesA/queryByCode/queryByCode'
  825. })
  826. }
  827. },
  828. // 去扫VIN
  829. openCamera(){
  830. if(this.hasLogin){
  831. // 游客身份
  832. if(this.userInfo.sysUserFlag == '0'){
  833. // 最多扫10次
  834. if(this.vuex_vinScanNums < this.scanMaxNums){
  835. uni.navigateTo({
  836. url: "/pages/scan-frame/scan-frame"
  837. })
  838. }else{
  839. uni.showModal({
  840. title: '提示',
  841. content: '个人用户扫描VIN仅限10次,您的次数已用完!',
  842. confirmText: '好的',
  843. showCancel: false,
  844. success(res) {}
  845. })
  846. }
  847. }else{
  848. // 非游客,直接扫
  849. uni.navigateTo({
  850. url: "/pages/scan-frame/scan-frame"
  851. })
  852. }
  853. }else{
  854. uni.navigateTo({
  855. url: '/pages/login/login'
  856. })
  857. }
  858. },
  859. // 查看扫描VIN记录
  860. toAllRecord(){
  861. uni.navigateTo({
  862. url: this.hasLogin ? "/pagesA/vinRecord/vinRecord" : '/pages/login/login'
  863. })
  864. },
  865. // 查看用户信息
  866. toUser(){
  867. if(this.hasLogin){
  868. // 用户详细信息 或 门店认证
  869. uni.navigateTo({
  870. url: this.userInfo.sysUserFlag == '1' ? '/pages/personData/personData' : '/pages/storeManage/storeAuth'
  871. })
  872. }else{
  873. uni.navigateTo({
  874. url: '/pages/login/login'
  875. })
  876. }
  877. },
  878. // 选择配件
  879. toChoosePart(item){
  880. item.text = item.modelInfo
  881. uni.navigateTo({
  882. url: "/pagesA/digitalShelf/choosePart?vinNumber="+item.vinCode+"&carList="+encodeURIComponent(JSON.stringify(item))+'&type=log'
  883. })
  884. }
  885. }
  886. }
  887. </script>
  888. <style lang="less">
  889. page{
  890. background-color: #ffffff;
  891. }
  892. .bg-0{
  893. background-image: linear-gradient(#86defa 0%,#cdeff9 25%,#ffffff 40%);
  894. }
  895. .bg-1{
  896. background-image: linear-gradient(#066cff 10%, #80b1fd 30%, #f8f8f8 50%);
  897. }
  898. .content {
  899. margin: 0;
  900. padding: 0;
  901. height: 100vh;
  902. display: flex;
  903. flex-direction: column;
  904. .header-box{
  905. z-index: 5;
  906. padding: 0em 1em;
  907. background: #066cff;
  908. .title{
  909. padding: 0;
  910. }
  911. .version{
  912. color: #FFEB3B;
  913. font-size: 0.8em;
  914. margin-left: 1em;
  915. }
  916. }
  917. .cbody{
  918. flex-grow: 1;
  919. overflow-y: auto;
  920. overflow-x: hidden;
  921. .notices{
  922. padding: 0.5em 0 0;
  923. font-size: 0.9em;
  924. margin-top: 0.5rem;
  925. view{
  926. color: #ffaf46;
  927. flex-grow: 1;
  928. }
  929. .text{
  930. color: #ffffff;
  931. margin-left: 1em;
  932. }
  933. }
  934. .pa-box{
  935. background: #fff;
  936. border-radius: 6px;
  937. margin: 10px 0;
  938. box-shadow: 1px 1px 3px #eee;
  939. }
  940. .product-box{
  941. margin: 10px 0;
  942. }
  943. .ptype-nav{
  944. padding: 10px 0;
  945. position: relative;
  946. .indicator-dots{
  947. width: 100%;
  948. height: 3px;
  949. display: flex;
  950. align-items: center;
  951. justify-content: center;
  952. position: absolute;
  953. left: 0;
  954. bottom:5px;
  955. }
  956. .indicator-dots > view{
  957. width: 10px;
  958. height: 3px;
  959. background: #e7e7e7;
  960. display: inline-block;
  961. }
  962. .indicator-dots >.indicator-dots-active{
  963. background: #00aaff;
  964. }
  965. }
  966. }
  967. .body-box{
  968. padding: 0em 1em 0.8em;
  969. z-index: 4;
  970. .banner{
  971. margin-top: 20rpx;
  972. }
  973. .action-button{
  974. padding:40upx 0 0 0;
  975. justify-content: space-between;
  976. > view{
  977. display: flex;
  978. align-items: center;
  979. color: #fff;
  980. border-radius: 10rpx;
  981. width: 49%;
  982. padding: 6rpx 0;
  983. box-shadow: 0rem 0.3rem 0.5rem #d9dada;
  984. }
  985. .f1{
  986. background: #2196f3;
  987. }
  988. .f2{
  989. background: #FF9800;
  990. }
  991. .icons{
  992. font-size: 50rpx;
  993. color: #fff;
  994. width: 80rpx;
  995. height: 80rpx;
  996. text-align:center;
  997. display: flex;
  998. align-items: center;
  999. flex-direction: column;
  1000. justify-content: center;
  1001. }
  1002. .tits{
  1003. font-size:28rpx;
  1004. }
  1005. }
  1006. }
  1007. .body-box1{
  1008. padding: 0em 10px 0.8em;
  1009. }
  1010. .bg-blue{
  1011. position: relative;
  1012. > view{
  1013. z-index: 100;
  1014. position: relative;
  1015. }
  1016. &::after{
  1017. /* 这个伪类的作用就是一个圆弧的背景色 */
  1018. width: 130%;
  1019. height: 100%;
  1020. position: absolute;
  1021. /*设置水平居中*/
  1022. left: -15%;
  1023. /* 之所以left:20%,是因为width:140%,若width:160%,那么left:30%才能水平居中 */
  1024. top: -10%;
  1025. /*层叠顺序,最底层显示*/
  1026. content: '';
  1027. border-radius: 0 0 50% 50%;
  1028. /*分别对应 左上 右上 右下 左下 可以修改成其它颜色*/
  1029. background: linear-gradient(to bottom, #066cff, #1d77ff);
  1030. }
  1031. .search-head{
  1032. }
  1033. .userCard{
  1034. position:relative;
  1035. left:0;
  1036. bottom:-0.8rem;
  1037. padding: 0.5rem;
  1038. background: #fff;
  1039. border-radius: 0.8rem;
  1040. box-shadow: 0rem 0.3rem 0.5rem #bcdede;
  1041. .userCard-info{
  1042. flex-grow:1;
  1043. > view{
  1044. &:last-child{
  1045. margin-left: 0.5em;
  1046. line-height: 1.5em;
  1047. .user-name{
  1048. font-size: 1rem;
  1049. }
  1050. >view{
  1051. padding: 0.2em;
  1052. }
  1053. }
  1054. }
  1055. .user-info{
  1056. flex-grow:1;
  1057. }
  1058. }
  1059. .user-rz{
  1060. font-size: 0.8rem;
  1061. color:#58aff5;
  1062. }
  1063. }
  1064. }
  1065. .shopping{
  1066. padding: 0;
  1067. .notices{
  1068. padding: 0.5em 10px 0
  1069. }
  1070. &::after{
  1071. top: -25px;
  1072. border-radius: 0 0 150px 150px;
  1073. }
  1074. }
  1075. .list-box{
  1076. padding: 0 1em;
  1077. overflow: auto;
  1078. .des{
  1079. text-align: center;
  1080. padding: 1em 0;
  1081. color: #999;
  1082. font-size: 0.8em;
  1083. }
  1084. }
  1085. }
  1086. </style>