promoDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <view class="video-pagesCons">
  3. <view class="tab-search">
  4. <u-search placeholder="请输入产品名称/轮胎规格" shape="round" :clearabled="true" show-action v-model="queryWord" @clear="getRow" @search="getRow" @custom="getRow"></u-search>
  5. </view>
  6. <view class="tab-body">
  7. <scroll-view scroll-y style="height: 100%;width: 100%;overflow: auto;" @scrolltolower="onreachBottom">
  8. <view class="product-list">
  9. <view
  10. class="check-order-list"
  11. v-for="(item,index) in 20"
  12. :key="item.id"
  13. >
  14. <view class="video-item">
  15. <view>
  16. <u-image :src="item.imageSet[0]" height="140px" width="100%"></u-image>
  17. <view class="back-price">返<text>¥15</text></view>
  18. </view>
  19. <view>
  20. <view class="product-name">箭冠轮胎285/70R17LT RT-5900 坦克300、长城炮、牧马人 D</view>
  21. <view class="product-guige"><text>编码:285/70R17LT RT-5900</text> <text>尺寸:17</text></view>
  22. <view class="product-button">
  23. <view class="price-txt">¥<text>325.63</text></view>
  24. <view>
  25. <u-button :throttle-time="50" @click="chooseProduct(item)" :custom-style="{width:'50rpx'}" size="mini" type="primary" shape="circle"><u-icon name="plus"></u-icon></u-button>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view style="padding: 20upx;">
  33. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  34. <u-loadmore v-if="(total>=list.length&&list.length)||status=='loading'" :status="status" />
  35. </view>
  36. </scroll-view>
  37. <!-- 底部栏 -->
  38. <view class="bottom-bar" @click="clearAction">
  39. <view class="bottom-bar-left">
  40. <view class="bottom-bar-left-item">
  41. <view class="bottom-bar-left-item-icon" @click="openChoose">
  42. <u-icon name="shopping-cart" size="40"></u-icon>
  43. <u-badge type="error" :count="chooseLength" :offset="[-7,-8]"></u-badge>
  44. </view>
  45. </view>
  46. <view class="bottom-bar-left-item">
  47. 合计:<view class="price-txt">¥<text>325.63</text></view>
  48. </view>
  49. </view>
  50. <view :class="'bottom-bar-right bg-'+(showChoosePopu?'1':'0')" @click="submitOrder">
  51. <view class="bottom-bar-right-item">{{showChoosePopu?'确认采购':'去结算'}}</view>
  52. </view>
  53. </view>
  54. <!-- 已选列表 -->
  55. <u-popup
  56. v-model="showChoosePopu"
  57. closeable
  58. :zIndex="100"
  59. mode="bottom"
  60. border-radius="14"
  61. height="80%"
  62. @open="openRender"
  63. @close="closePopu">
  64. <view :style="{width:screenWidth + 'px'}" @click="clearAction">
  65. <view class="choose-title">
  66. <view>已选<text class="p-nums">{{chooseLength}}</text>款产品 </view>
  67. <u-button @click="claerChoose" size="mini" type="error" plain style="margin: 0 20upx;">清空列表</u-button>
  68. </view>
  69. <view class="choose-product-list" v-if="showSwipeAction">
  70. <u-swipe-action
  71. :show="item.show"
  72. :index="index"
  73. v-for="(item, index) in chooseProductList"
  74. :key="item.id"
  75. @click="chooseClick"
  76. @open="chooseOpen"
  77. :options="chooseOptions"
  78. >
  79. <view class="choose-product-item">
  80. <view>
  81. <view class="choose-product-item-img">
  82. <u-image :src="item.images" height="200rpx" width="100%"></u-image>
  83. <view class="back-price">返<text>¥15</text></view>
  84. </view>
  85. <view class="choose-product-item-info">
  86. <view class="ellipsis-two choose-product-item-left-info-name">箭冠轮胎285/70R17LT RT-5900 坦克300、长城炮、牧马人 D</view>
  87. <view class="choose-product-item-left-info-guige"><text>编码:285/70R17LT RT-5900</text> <text>尺寸:17</text></view>
  88. <view class="choose-product-item-left-info-price">
  89. <view class="price-txt">¥<text>325.63</text></view>
  90. <view>
  91. <u-number-box :input-width="60" :input-height="60" size="mini"></u-number-box>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </u-swipe-action>
  98. </view>
  99. </view>
  100. </u-popup>
  101. </view>
  102. </view>
  103. </view>
  104. </template>
  105. <script>
  106. import {
  107. mapState,
  108. mapMutations,
  109. } from 'vuex'
  110. import { promoTerminalList } from '@/api/video.js'
  111. export default {
  112. data() {
  113. return {
  114. status: 'loading',
  115. noDataText: '暂无数据',
  116. queryWord: '',
  117. // 查询条件
  118. pageNo: 1,
  119. pageSize: 10,
  120. list: [],
  121. total: 0,
  122. showChoosePopu: false,
  123. chooseList:[],
  124. chooseProductList:[],
  125. chooseOptions:
  126. [
  127. {
  128. text: '删除',
  129. style: {
  130. backgroundColor: '#dd524d'
  131. }
  132. }
  133. ],
  134. screenWidth: 750,
  135. showSwipeAction: false
  136. }
  137. },
  138. computed: {
  139. ...mapState(['hasLogin']),
  140. userInfo(){
  141. return this.$store.state.vuex_userInfo
  142. },
  143. chooseLength(){
  144. return this.chooseList.length
  145. }
  146. },
  147. onLoad(opts) {
  148. uni.setNavigationBarTitle({
  149. title: opts.title||'促销活动产品'
  150. })
  151. this.pageInit()
  152. },
  153. methods: {
  154. pageInit(){
  155. this.screenWidth = uni.getSystemInfoSync().windowWidth
  156. this.total = 0
  157. this.pageNo = 1
  158. this.getRow()
  159. },
  160. // 添加已选产品
  161. chooseProduct(item){
  162. this.chooseList.push({
  163. id: new Date().getTime(),
  164. title: '长安回望绣成堆,山顶千门次第开,一骑红尘妃子笑,无人知是荔枝来',
  165. images: 'https://cdn.uviewui.com/uview/common/logo.png',
  166. show: false
  167. })
  168. this.showChoosePopu = false
  169. },
  170. openRender(){
  171. this.chooseProductList = JSON.parse(JSON.stringify(this.chooseList))
  172. setTimeout(()=>{
  173. this.showSwipeAction = true
  174. },100)
  175. },
  176. closePopu(){
  177. this.chooseProductList = []
  178. this.showChoosePopu=false
  179. },
  180. // 打开已选产品列表
  181. openChoose(){
  182. if(this.chooseLength){
  183. this.showChoosePopu = !this.showChoosePopu
  184. }else{
  185. this.$u.toast(`请选择产品`);
  186. }
  187. },
  188. //已选产品删除
  189. chooseClick(index, btns){
  190. if(btns == 0) {
  191. this.chooseList.splice(index, 1);
  192. this.chooseProductList.splice(index, 1);
  193. this.$u.toast(`删除了第${index}个cell`);
  194. }
  195. },
  196. // 同时打开一个
  197. chooseOpen(index){
  198. // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
  199. // 原本为'false',再次设置为'false'会无效
  200. this.chooseProductList[index].show = true;
  201. this.chooseProductList.map((val, idx) => {
  202. if(index != idx) this.chooseProductList[idx].show = false;
  203. })
  204. },
  205. // 清除滑动按钮
  206. clearAction(){
  207. this.chooseProductList.map(item => {
  208. item.show = false
  209. })
  210. this.chooseProductList.splice()
  211. },
  212. // 清空已选列表
  213. claerChoose(){
  214. const _this = this
  215. uni.showModal({
  216. title: '提示',
  217. content: '确定清空已选列表?',
  218. confirmText: '确定',
  219. success(res) {
  220. if(res.confirm){
  221. _this.chooseList = []
  222. _this.chooseProductList = []
  223. _this.showChoosePopu = false
  224. }
  225. }
  226. })
  227. },
  228. // scroll-view到底部加载更多
  229. onreachBottom() {
  230. if(this.list.length < this.total){
  231. this.pageNo += 1
  232. this.getRow()
  233. }else{
  234. this.status = "nomore"
  235. }
  236. },
  237. // 查询列表
  238. getRow (pageNo) {
  239. let _this = this
  240. if (pageNo) {
  241. this.pageNo = pageNo
  242. }
  243. let params = {
  244. pageNo: this.pageNo,
  245. pageSize: this.pageSize,
  246. queryWord: this.queryWord
  247. }
  248. const storeShelf = this.$store.state.vuex_storeShelf
  249. this.status = "loading"
  250. promoTerminalList({sn:storeShelf.dealerSn,contentType:'LINK'}).then(res => {
  251. if (res.code == 200 || res.status == 204 || res.status == 200) {
  252. // const list = res.data.list || []
  253. // if(_this.pageNo>1){
  254. // _this.list = _this.list.concat(list)
  255. // }else{
  256. // _this.list = list
  257. // }
  258. // _this.total = res.data.count || 0
  259. _this.list = res.data.filter(item => item.content.indexOf("pages/promo/index") >= 0)
  260. _this.total = _this.list.length
  261. } else {
  262. _this.list = []
  263. _this.total = 0
  264. _this.noDataText = res.message
  265. }
  266. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  267. })
  268. },
  269. // 提交订单
  270. submitOrder(){
  271. if(this.showChoosePopu){
  272. uni.navigateTo({
  273. url: '/pagesB/procureOrder?id='
  274. })
  275. }else{
  276. this.openChoose()
  277. }
  278. },
  279. }
  280. }
  281. </script>
  282. <style lang="less">
  283. page{
  284. height: 100vh;
  285. }
  286. .video-pagesCons{
  287. height: 100vh;
  288. display: flex;
  289. flex-direction: column;
  290. .tab-search{
  291. padding: 15rpx 20rpx;
  292. background: #fff;
  293. }
  294. .tab-body{
  295. display: flex;
  296. flex-direction: column;
  297. flex-grow: 1;
  298. overflow: auto;
  299. .bottom-bar{
  300. height: 150upx;
  301. z-index: 500;
  302. background-color: #fff;
  303. display: flex;
  304. align-items: center;
  305. justify-content: space-between;
  306. font-size: 32upx;
  307. .bottom-bar-left{
  308. padding: 0 30upx;
  309. flex-grow: 1;
  310. display: flex;
  311. align-items: center;
  312. }
  313. .bottom-bar-left-item{
  314. padding-right: 20rpx;
  315. font-size: 24rpx;
  316. display: flex;
  317. align-items: center;
  318. }
  319. .bottom-bar-left-item-icon{
  320. position: relative;
  321. background: #2196F3;
  322. padding: 20rpx;
  323. border-radius: 100%;
  324. color: #fff;
  325. }
  326. .bottom-bar-right{
  327. padding: 0 50rpx;
  328. height: 100%;
  329. background: #2196F3;
  330. display: flex;
  331. align-items: center;
  332. .bottom-bar-right-item{
  333. color: #fff;
  334. }
  335. }
  336. .bg-0{
  337. background: #2196F3;
  338. }
  339. .bg-1{
  340. background: #f44336;
  341. }
  342. }
  343. .product-list{
  344. display: flex;
  345. flex-wrap: wrap;
  346. }
  347. .check-order-list{
  348. width: 50%;
  349. padding: 10upx;
  350. .video-item{
  351. background: #ffffff;
  352. border-radius: 10upx;
  353. box-shadow: 1px 1px 3px #EEEEEE;
  354. > view{
  355. &:first-child{
  356. position: relative;
  357. overflow: hidden;
  358. }
  359. &:last-child{
  360. padding: 20rpx;
  361. .product-guige{
  362. margin: 10rpx 0;
  363. color: #666;
  364. text{
  365. margin-right: 10rpx;
  366. }
  367. }
  368. }
  369. .product-button{
  370. display: flex;
  371. justify-content: space-between;
  372. align-items: center;
  373. }
  374. }
  375. }
  376. }
  377. }
  378. .price-txt{
  379. color: red;
  380. text{
  381. font-size: 36rpx;
  382. }
  383. }
  384. .choose-title{
  385. display: flex;
  386. align-items:center;
  387. padding: 30rpx;
  388. position: fixed;
  389. background: #fff;
  390. width: 100%;
  391. z-index: 3;
  392. .p-nums{
  393. color: #2196F3;
  394. margin: 0 6rpx;
  395. }
  396. }
  397. .choose-product-list{
  398. padding: 100rpx 20rpx 150rpx;
  399. width: 100%;
  400. .choose-product-item{
  401. display: flex;
  402. align-items: center;
  403. justify-content: space-between;
  404. padding: 20rpx 0;
  405. border-bottom: 1px solid #eee;
  406. > view{
  407. display: flex;
  408. align-items: center;
  409. justify-content: space-between;
  410. flex-grow: 1;
  411. width: 100%;
  412. }
  413. .choose-product-item-img{
  414. margin-right: 10rpx;
  415. width: 35%;
  416. position: relative;
  417. overflow: hidden;
  418. .back-price{
  419. zoom: calc(0.8);
  420. }
  421. }
  422. .choose-product-item-info{
  423. margin-right: 10rpx;
  424. width: 65%;
  425. flex-grow: 1;
  426. .choose-product-item-left-info-price{
  427. display: flex;
  428. align-items:center;
  429. justify-content: space-between;
  430. >view{
  431. &:last-child{
  432. display: flex;
  433. align-items:center;
  434. }
  435. }
  436. }
  437. .choose-product-item-left-info-guige{
  438. color: #666;
  439. margin: 10rpx 0;
  440. text{
  441. margin-right: 10rpx;
  442. }
  443. }
  444. }
  445. }
  446. }
  447. .back-price{
  448. padding: 6rpx 55rpx;
  449. background: rgb(255 87 34 / 0.6);
  450. position: absolute;
  451. top: 16rpx;
  452. left: -50rpx;
  453. color: #fff;
  454. z-index: 2;
  455. font-size: 20rpx;
  456. text-align: center;
  457. transform: rotate(-40deg);
  458. display: flex;
  459. align-items: center;
  460. text{
  461. font-size: 28rpx;
  462. }
  463. }
  464. }
  465. </style>