home.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <view>
  3. <view class="search">
  4. <view style="margin: 10rpx 20rpx;margin-top: 20rpx;">
  5. <u-search placeholder="请输入商品名称" inputAlign="center" bgColor="#fff" shape="square" v-model="search.cname"
  6. @search="searchButton" @custom="searchButton" :animation="true"></u-search>
  7. </view>
  8. <view v-if="false" style="margin: -15rpx auto 10rpx auto;display: flex;padding: 0 20rpx;z-index: 999;" >
  9. <u-tag :text="search.brandNmae" borderColor="#FD4B09" color="#FD4B09" plain size="medium" closable
  10. :show="false" @close="close" @click="close"></u-tag>
  11. <!-- <u-tag text="原厂" borderColor="#FD4B09" color="#FD4B09" plain size="medium" closable v-if="originalFactory"
  12. :show="originalFactory" @close="yuanchangclose('originalFactory')" @click="yuanchangclose('originalFactory')"></u-tag>
  13. <u-tag text="自修补" borderColor="#FD4B09" color="#FD4B09" plain size="medium" closable v-if="selfRecovery"
  14. :show="selfRecovery" @close="yuanchangclose('selfRecovery')" @click="yuanchangclose('selfRecovery')"></u-tag>
  15. <u-tag text="防爆" borderColor="#FD4B09" color="#FD4B09" plain size="medium" closable v-if="explosionProof"
  16. :show="explosionProof" @close="yuanchangclose('explosionProof')" @click="yuanchangclose('explosionProof')"></u-tag> -->
  17. </view>
  18. </view>
  19. <view :style="{marginTop:show == true?'108rpx':'108rpx'}">
  20. <u-swiper :list="list3" indicator indicatorMode="dot" circular></u-swiper>
  21. </view>
  22. <view style="background-color: #fff;margin-bottom: 20rpx;">
  23. <view style="padding: 20rpx 0 0 0;">
  24. <u-grid :border="false" @click="click" col="4">
  25. <u-grid-item v-for="(item,index) in brandList" :key="index">
  26. <view v-if="item.brandFilesList.length>0" style="text-align: center;">
  27. <view v-for="(li,i) in item.brandFilesList" :key="i" :src="li.url">
  28. <image :src="li.url" style="width: 80rpx;height: 80rpx;"></image>
  29. <view style="font-size: 28rpx;" :style="PPindex == index?'color:#3c9cff':''" >{{item.cname}}</view>
  30. </view>
  31. </view>
  32. <view v-else style="text-align: center;">
  33. <u-icon :customStyle="{paddingBottom:8+'rpx'}" labelPos="bottom" name="error-circle"
  34. :size="40"></u-icon>
  35. <view style="font-size: 28rpx;">{{item.cname}}</view>
  36. </view>
  37. </u-grid-item>
  38. </u-grid>
  39. </view>
  40. <view style="margin-top: 10rpx;display: flex;">
  41. <u-tabs :list="dianjiqielist" v-model="groupModel" @click="groupChange"></u-tabs>
  42. <!-- <u-radio-group
  43. v-model="groupModel"
  44. placement="row"
  45. @change="groupChange"
  46. >
  47. <u-radio
  48. :customStyle="{margin: '0 10px'}"
  49. v-for="(item, index) in dianjiqielist"
  50. :key="index"
  51. :label="item.name"
  52. :name="item.name" >
  53. </u-radio>
  54. </u-radio-group> -->
  55. <!-- <view style="display: flex;align-items: center;" @click="dianjiqiehuan('')">
  56. <view style="margin-right: 10rpx;"
  57. :style="originalFactory?'color:#4070fc':''">全部</view>
  58. </view>
  59. <view style="display: flex;align-items: center;" @click="dianjiqiehuan('originalFactory')">
  60. <view style="margin-right: 10rpx;"
  61. :style="originalFactory?'color:#4070fc':''">静音棉</view>
  62. </view>
  63. <view style="display: flex;align-items: center;" @click="dianjiqiehuan('selfRecovery')">
  64. <view style="margin-right: 10rpx;" :style="selfRecovery?'color:#4070fc':''">自修补</view>
  65. </view>
  66. <view style="display: flex;align-items: center;" @click="dianjiqiehuan('explosionProof')">
  67. <view style="margin-right: 10rpx;" :style="explosionProof?'color:#4070fc':''">防爆</view>
  68. </view> -->
  69. </view>
  70. <view style="padding: 20rpx 20rpx;">
  71. <u-divider text="爆品推荐"></u-divider>
  72. </view>
  73. </view>
  74. <view style="margin-top: 0rpx;" class="content">
  75. <view class="left">
  76. <block v-for="(item,index) in dataList" :key="index" v-if="index%2==0">
  77. <view class="item" @click="choice(item,index)">
  78. <image v-for="(ite,ind) in item.filesList" :key="ind" v-if="ite.version === '0'" :src="ite.url"
  79. style="width: 100%;height: 340rpx;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;">
  80. </image>
  81. <view style="width: calc(100% - 20rpx);margin: 0 auto;">
  82. <u--text :text="item.cname" size="12"></u--text>
  83. <view style="display: flex;justify-content: space-between;margin: 5rpx auto;">
  84. <view style="padding-top: 12rpx;">
  85. <view v-if="item.billType == 0"
  86. style="font-size: 16rpx;background-color: #FD4B09;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  87. 今日达</view>
  88. <view v-else
  89. style="font-size: 16rpx;background-color: #5ac725;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  90. 次日达</view>
  91. </view>
  92. <view style="color: #FD4B09;font-size: 40rpx;">¥{{item.mallPrice}}</view>
  93. </view>
  94. </view>
  95. </view>
  96. </block>
  97. </view>
  98. <view class="right">
  99. <block v-for="(item,index) in dataList" :key="index" v-if="index%2==1">
  100. <view class="item" @click="choice(item,index)">
  101. <image v-for="(ite,ind) in item.filesList" :key="ind" v-if="ite.version === '0'" :src="ite.url"
  102. style="width: 100%;height: 340rpx;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;">
  103. </image>
  104. <view style="width: calc(100% - 20rpx);margin: 0 auto;">
  105. <u--text :text="item.cname" size="12"></u--text>
  106. <view style="display: flex;justify-content: space-between;margin: 5rpx auto;">
  107. <view style="padding-top: 12rpx;">
  108. <view v-if="item.billType == 0"
  109. style="font-size: 16rpx;background-color: #FD4B09;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  110. 今日达</view>
  111. <view v-else
  112. style="font-size: 16rpx;background-color: #5ac725;color: #fff;padding: 6rpx;border-radius: 6rpx;">
  113. 次日达</view>
  114. </view>
  115. <view style="color: #FD4B09;font-size: 40rpx;">¥{{item.mallPrice}}</view>
  116. </view>
  117. </view>
  118. </view>
  119. </block>
  120. </view>
  121. </view>
  122. <u-empty v-if="dataList.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
  123. <u-loadmore v-if="page.total !== 0 && dataList.length != 0" :status="status" />
  124. </view>
  125. </template>
  126. <script>
  127. import {
  128. appList,
  129. userDept,
  130. validationCorpEmpty,
  131. brandDescList,
  132. brandDescDetail
  133. } from '@/api/tabBar/home.js'
  134. import {
  135. listAll
  136. } from '@/api/tabBar/classification.js'
  137. export default {
  138. data() {
  139. return {
  140. show:false,
  141. search: {},
  142. page: {
  143. total: 0,
  144. size: 10,
  145. current: 1
  146. },
  147. status: 'loadmore',
  148. dataList: [],
  149. list3: [],
  150. brandList: [],
  151. // 静音棉
  152. originalFactory:0,
  153. // 自修补
  154. selfRecovery:0,
  155. // 防爆
  156. explosionProof:0,
  157. dianjiqielist:[
  158. {
  159. name: '全部',
  160. },
  161. {
  162. name: '静音棉',
  163. },
  164. {
  165. name: '自修补',
  166. },
  167. {
  168. name: '防爆',
  169. }
  170. ],
  171. groupModel:null,
  172. PPindex:null,
  173. }
  174. },
  175. onReachBottom() {
  176. this.status = 'loading'
  177. if (this.dataList.length < this.page.total) {
  178. this.page.current++
  179. this.onSearch()
  180. } else {
  181. this.status = 'nomore'
  182. }
  183. },
  184. onShow() {
  185. // 轮播图
  186. brandDescList({type:'LBT'}).then(res=>{
  187. brandDescDetail({id:res.data.records[0].id}).then(res=>{
  188. // this.list3 = res.data.brandFilesList
  189. this.list3 = res.data.brandFilesList.map(item=>{
  190. return item.url
  191. })
  192. })
  193. })
  194. uni.showLoading({
  195. title: '加载中',
  196. mask: true
  197. });
  198. validationCorpEmpty().then(res => {
  199. uni.hideLoading();
  200. //获取公司名称
  201. userDept().then(res => {
  202. uni.setNavigationBarTitle({
  203. title: res.data.fullName
  204. })
  205. })
  206. //获取所有品牌
  207. listAll({type:'PP', enableOrNot:'1'}).then(res => {
  208. this.brandList = res.data
  209. })
  210. this.page = {
  211. total: 0,
  212. size: 10,
  213. current: 1
  214. }
  215. this.dataList = []
  216. this.onSearch()
  217. }).catch(err => {
  218. uni.hideLoading();
  219. uni.$u.route('/pages/views/personalInformation/index');
  220. })
  221. },
  222. methods: {
  223. groupChange(e){
  224. console.log(e,228);
  225. if (e.name == '静音棉') {
  226. this.originalFactory = 1
  227. this.selfRecovery = 0
  228. this.explosionProof = 0
  229. }else if (e.name == '自修补') {
  230. this.originalFactory = 0
  231. this.selfRecovery = 1
  232. this.explosionProof = 0
  233. }else if (e.name == '防爆') {
  234. this.originalFactory = 0
  235. this.selfRecovery = 0
  236. this.explosionProof = 1
  237. }else {
  238. this.originalFactory = 0
  239. this.selfRecovery = 0
  240. this.explosionProof = 0
  241. }
  242. this.page.current = 1
  243. this.dataList = []
  244. this.onSearch()
  245. },
  246. // 点击筛选条件
  247. dianjiqiehuan(name){
  248. if (this[name] == 0) {
  249. this[name] = 1
  250. }else {
  251. this[name] = 0
  252. }
  253. this.click()
  254. },
  255. // 获取列表数据
  256. onSearch() {
  257. uni.showLoading({
  258. title: '加载中',
  259. mask: true
  260. });
  261. let obj = {}
  262. if(this.originalFactory){
  263. obj.originalFactory = 1
  264. }
  265. if (this.selfRecovery){
  266. obj.selfRecovery = 1
  267. }
  268. if (this.explosionProof) {
  269. obj.explosionProof = 1
  270. }
  271. appList({
  272. size: this.page.size,
  273. current: this.page.current,
  274. ...obj,
  275. ...this.search
  276. }).then(res => {
  277. this.dataList = this.dataList.concat(res.data.records)
  278. this.page.total = res.data.total
  279. if (this.dataList.length == res.data.total) {
  280. this.status = 'nomore'
  281. }
  282. uni.hideLoading();
  283. }).catch(err => {
  284. uni.hideLoading();
  285. })
  286. },
  287. close(){
  288. this.show = false
  289. this.search.brandId = ''
  290. this.search.brandName = ''
  291. },
  292. // 原厂点击差号
  293. yuanchangclose(type){
  294. if (type == 'originalFactory') {
  295. this.originalFactory = false
  296. }else if (type == 'selfRecovery') {
  297. this.selfRecovery = false
  298. }else {
  299. this.explosionProof = false
  300. }
  301. this.click()
  302. },
  303. click(name) {
  304. if (name != undefined) {
  305. this.page = {
  306. total: 0,
  307. size: 10,
  308. current: 1,
  309. }
  310. this.dataList = []
  311. if (this.PPindex == name) {
  312. this.PPindex = null
  313. delete this.search.brandId
  314. delete this.search.brandNmae
  315. }else {
  316. this.PPindex = name
  317. this.search = {
  318. ...this.search,
  319. brandId: this.brandList[this.PPindex].id,
  320. brandNmae: this.brandList[this.PPindex].cname,
  321. }
  322. }
  323. }
  324. this.show = true
  325. this.onSearch()
  326. },
  327. searchButton(value) {
  328. this.dataList = []
  329. this.page = {
  330. total: 0,
  331. size: 10,
  332. current: 1
  333. }
  334. this.search = {
  335. ...this.search,
  336. cname: value,
  337. }
  338. this.onSearch()
  339. },
  340. //打开明细
  341. choice(item, index) {
  342. uni.$u.route('/pages/views/buyGoods/commodityDetails', {
  343. id: item.id
  344. });
  345. },
  346. }
  347. }
  348. </script>
  349. <style lang="scss" scoped>
  350. ::v-deep .u-divider {
  351. margin: 0 !important;
  352. }
  353. .content {
  354. text-align: justify;
  355. }
  356. .left,
  357. .right {
  358. display: inline-block;
  359. vertical-align: top;
  360. width: 50%;
  361. }
  362. .item {
  363. width: calc(100% - 20rpx);
  364. margin: 0 auto;
  365. background-color: #FFFFFF;
  366. border-radius: 10rpx;
  367. break-inside: avoid;
  368. margin-bottom: 20rpx;
  369. }
  370. .search {
  371. width: 100%;
  372. position: fixed;
  373. top: 0;
  374. z-index: 8;
  375. background-color: #f2f2f2;
  376. }
  377. </style>