shop.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <template>
  2. <view class="main main-bg">
  3. <!-- <view class="other" @click="handleOther">
  4. 其他商品
  5. </view> -->
  6. <view class="view-list" v-if="list.length > 0">
  7. <view class="item" v-for="(item, index) in list">
  8. <image :src="image(item.goodsPic)" @tap="preAvatar(image(item.goodsPic))"></image>
  9. <view class="item-footer">
  10. <view class="name font-twenty">{{item.goodsName}}</view>
  11. <view class="yuan font-twenty font-color2">商品原价: ¥{{item.goodsRatePrice ?item.goodsRatePrice : 1}}</view>
  12. <view class="yuan font-twenty font-color5">商品折扣: {{item.goodsPrice ? item.goodsPrice : 1}}</view>
  13. <view class="yuan font-twenty font-color5">折扣价格: ¥{{ (item.goodsRatePrice*(item.goodsPrice||1)).toFixed(1) }}</view>
  14. <view class="icon">
  15. <u-icon name="heart" size="32" v-if="!item.show" @click="handleShow(index, item.show, item)"></u-icon>
  16. <u-icon name="heart-fill" size="32" color="#CC1019" v-if="item.show" @click="handleShow(index, item.show, item)"></u-icon>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <view style="text-align: center; padding-top: 100rpx;" v-else>
  22. <u-empty mode="list"></u-empty>
  23. </view>
  24. <view class="footer">
  25. <view class="left header-long-bg font-color1 font-thirty" @click="handleGou">购买结算</view>
  26. <view class="right font-color2 font-thirty" @click="goto">返回店铺</view>
  27. </view>
  28. <u-popup ref="order" mode="bottom" v-model="showPopup" length="100%">
  29. <!-- <ming-pop ref="order" direction="below" :is_mask="true" :width="100" height="100%" :maskFun="true"> -->
  30. <u-icon style="padding-left: calc(100% - 80rpx); padding-top: 20rpx;" size="32" name="backspace" @click="close()"></u-icon>
  31. <view class="order-list main-bg">
  32. <scroll-view scroll-y="true" style="height: 100%;">
  33. <view class="order-item" v-for="(item, index) in newList">
  34. <view class="order-item-header">
  35. <image :src="image(item.goodsPic)" @tap="preAvatar(image(item.goodsPic))"></image>
  36. <view class="order-item-header-right">
  37. <view class="name font-twenty">{{item.goodsName}}</view>
  38. <view class="yuan font-twenty font-color2">商品原价: ¥{{item.goodsRatePrice ?item.goodsRatePrice : 0}}</view>
  39. <view class="yuan font-twenty font-color5">
  40. <span style="padding-right: 32rpx;">商品折扣: {{item.goodsPrice ? item.goodsPrice : 1}}</span>
  41. <u-icon name="edit-pen" @click="handleShowZhe(index, item)"></u-icon>
  42. </view>
  43. <view class="name font-twenty" style="padding-top: 20rpx;">
  44. <span style="padding-right: 15rpx;">数量: </span>
  45. <u-icon name="minus-circle" @click="handleJian(index, item)"></u-icon>
  46. <span style="color: #000; padding-left: 20rpx; padding-right: 20rpx;" @click="changeNum(index, item)">{{item.num}}</span>
  47. <u-icon name="plus-circle" @click="handleJia(index, item)"></u-icon>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="order-item-footer font-twenty font-color2">
  52. 单价: {{ (item.all || 0).toFixed(2) }}
  53. </view>
  54. </view>
  55. </scroll-view>
  56. <view class="footer1">
  57. <view class="total font-color2 font-twenty">合计: ¥{{ (total || 0).toFixed(2) }}</view>
  58. <view class="left header-long-bg font-color1 font-thirty" @click="handleTotal">调整折扣</view>
  59. <view class="right font-color2 font-thirty" @click="handleAdd">确认结算</view>
  60. </view>
  61. </view>
  62. </u-popup>
  63. <!-- </ming-pop> -->
  64. <!-- <ming-pop ref="zhe" direction="below" :is_mask="true" :width="100" height="50%" :maskFun="true"> -->
  65. <u-popup ref="zhe" mode="bottom" v-model="showZhe" length="45%">
  66. <zhe @close="closeZhe()" ref="zheli" @add="changeZhe" @total="changeTotal"></zhe>
  67. </u-popup>
  68. <!-- </ming-pop> -->
  69. <!-- <ming-pop ref="number" direction="below" :is_mask="true" :width="100" height="50%" :maskFun="true"> -->
  70. <u-popup ref="number" mode="bottom" v-model="showNumber" length="45%">
  71. <count @close="closeCount()" ref="count" @add="changeCount"></count>
  72. </u-popup>
  73. <u-popup ref="img" mode="bottom" v-model="showImg" length="100%">
  74. <view class="liet">
  75. <view class="title">
  76. <u-icon name="close" @click="closeImg()"></u-icon>
  77. </view>
  78. <view class="font-color2 font-twenty">上传证件</view>
  79. <u-upload
  80. width="160"
  81. height="160"
  82. :action="action"
  83. max-count="3"
  84. @on-success="onSuccess">
  85. </u-upload>
  86. <view class="right1 font-color2 font-thirty" @click="handleSubmit">确认</view>
  87. </view>
  88. </u-popup>
  89. <!-- </ming-pop> -->
  90. <u-toast ref="uToast" />
  91. </view>
  92. </template>
  93. <script>
  94. import server from "@/api/index";
  95. import http from '@/common/http.js'
  96. import zhe from '@/components/pop/zhe.vue'
  97. import count from '@/components/pop/count.vue'
  98. export default {
  99. components:{
  100. zhe,
  101. count
  102. },
  103. data() {
  104. return {
  105. action: http.webUrl+`/wx/common/upload`,
  106. userInfo: null,
  107. showPopup: false,
  108. showZhe: false,
  109. showNumber: false,
  110. showImg: false,
  111. userId: 0,
  112. type: '',
  113. total: null,
  114. yuan: null,
  115. list: [],
  116. newList: [],
  117. picUrlList: [],
  118. discount: 1,
  119. youhuiTotal: 0,
  120. veteransName: ''
  121. }
  122. },
  123. onLoad(e) {
  124. this.userInfo = uni.getStorageSync('userInfo');
  125. if(e.userId){
  126. this.userId = parseInt(e.userId);
  127. this.type = e.type;
  128. this.veteransName = e.veteransName
  129. }
  130. this.getListFn(this.userInfo.nickName);
  131. setTimeout(function () {
  132. }, 1000);
  133. uni.startPullDownRefresh();
  134. },
  135. onPullDownRefresh() {
  136. this.userInfo = uni.getStorageSync('userInfo');
  137. this.getListFn(this.userInfo.nickName);
  138. setTimeout(function () {
  139. uni.stopPullDownRefresh();
  140. }, 1000);
  141. },
  142. methods:{
  143. handleGou(){
  144. if(this.newList.length > 0){
  145. this.showPopup = true;
  146. }else{
  147. // this.showImg = true;
  148. this.handleOther();
  149. }
  150. },
  151. onSuccess(data, index, lists, name){
  152. console.log(data, index, lists, name)
  153. this.picUrlList = [];
  154. lists.forEach(item =>{
  155. this.picUrlList.push(item.response.fileName)
  156. })
  157. console.log('data.fileName', data.fileName)
  158. console.log('this.picUrlList ',this.picUrlList)
  159. },
  160. handleAdd(){
  161. this.showImg = true;
  162. // this.handleSubmit();
  163. },
  164. handleSubmit(){
  165. console.log('newList', this.newList)
  166. console.log('this.picUrlList handleSubmit',this.picUrlList)
  167. let detailedlist = [];
  168. this.newList.forEach(item =>{
  169. detailedlist.push({
  170. shopsName: item.goodsName,
  171. shopsNum: item.num,
  172. priceOld: item.goodsRatePrice,
  173. priceVip: item.goodsPrice*item.goodsRatePrice
  174. })
  175. })
  176. console.log(detailedlist)
  177. let that = this;
  178. uni.showModal({
  179. title: '提示',
  180. content: '确认结算吗?',
  181. success: function (res) {
  182. if (res.confirm) {
  183. let params = {
  184. shopsId: that.userInfo.nickName,
  185. goodsName: that.userInfo.userName,
  186. veteransName: that.veteransName,
  187. veteransId: that.userId,
  188. remark: that.type,
  189. orderPriceOld: that.yuan,
  190. orderPriceVip: that.total,
  191. picUrlList: that.picUrlList,
  192. detailedlist: detailedlist
  193. }
  194. console.log('params', params)
  195. server.addOrderInfo(params).then(res =>{
  196. that.$refs.uToast.show({
  197. title: '操作成功!',
  198. type: 'default',
  199. })
  200. setTimeout(function() {
  201. uni.switchTab({
  202. url: '/pages/index/index'
  203. })
  204. }, 2000);
  205. })
  206. } else if (res.cancel) {
  207. console.log('用户点击取消');
  208. }
  209. }
  210. });
  211. },
  212. changeTotal(data){
  213. console.log(data)
  214. this.total = this.youhuiTotal*data;
  215. this.discount = data;
  216. },
  217. handleTotal(){
  218. console.log("99999")
  219. this.showZhe = true;
  220. // this.$refs.zhe.show();
  221. this.$refs.zheli.show();
  222. },
  223. changeNum(index, item){
  224. this.showNumber = true;
  225. // this.$refs.number.show(); this.$refs.count.shows(item.goodsPrice, item.goodsRatePrice, index);
  226. },
  227. handleShowZhe(index, item){
  228. // this.$refs.zhe.show();
  229. this.showZhe = true;
  230. this.$refs.zheli.shows(item.goodsPrice, item.goodsRatePrice, item.num, index);
  231. },
  232. handleJian(index, item){
  233. if(this.newList[index].num >= 1){
  234. this.newList[index].num = this.newList[index].num - 1;
  235. this.newList[index].all = item.goodsRatePrice*(item.goodsPrice || 1)*item.num;
  236. this.total =null;
  237. this.goodsRatePrice =null;
  238. this.yuan = null;
  239. this.newList.forEach(item =>{
  240. console.log(item.goodsRatePrice, item.num)
  241. this.total += item.all;
  242. this.yuan += parseFloat(item.goodsRatePrice)*item.num;
  243. })
  244. this.youhuiTotal = this.total;
  245. this.total = this.total * this.discount;
  246. }
  247. },
  248. handleJia(index, item){
  249. this.newList[index].num = this.newList[index].num + 1
  250. this.newList[index].all = item.goodsRatePrice*(item.goodsPrice || 1)*item.num;
  251. this.total =null;
  252. this.goodsRatePrice =null;
  253. this.yuan = null;
  254. this.newList.forEach(item =>{
  255. console.log(item.goodsRatePrice, item.num)
  256. this.total += item.all;
  257. this.yuan += parseFloat(item.goodsRatePrice)*item.num;
  258. })
  259. this.youhuiTotal = this.total;
  260. this.total = this.total * this.discount;
  261. },
  262. changeCount(num, goodsPrice, goodsRatePrice, index){
  263. this.newList[index].num =num
  264. this.newList[index].all =goodsRatePrice*goodsPrice*num
  265. this.total =null;
  266. this.goodsRatePrice =null;
  267. this.yuan = null;
  268. this.newList.forEach(item =>{
  269. this.total += parseFloat(item.all);
  270. this.yuan += parseFloat(item.goodsRatePrice)*item.num;
  271. })
  272. this.youhuiTotal = this.total;
  273. this.total = this.total * this.discount;
  274. },
  275. changeZhe(data, goodsRatePrice,num, index){
  276. this.newList[index].goodsPrice =data
  277. this.newList[index].all =goodsRatePrice*data*num
  278. this.total =null;
  279. this.goodsRatePrice =null;
  280. this.yuan = null;
  281. this.newList.forEach(item =>{
  282. this.total += parseFloat(item.all);
  283. console.log(item.goodsRatePrice, item.num)
  284. this.yuan += parseFloat(item.goodsRatePrice)*item.num;
  285. })
  286. this.youhuiTotal = this.total;
  287. this.total = this.total * this.discount;
  288. },
  289. goto(){
  290. uni.reLaunch({
  291. url: '/pages/index/index'
  292. })
  293. },
  294. handleOther(){
  295. uni.navigateTo({
  296. url: '/pages/merchant/home/account?veteransName='+ this.veteransName + '&veteransId=' + this.userId + '&remark=' + this.type
  297. })
  298. },
  299. show() {
  300. this.$refs.order.show();
  301. },
  302. closeZhe() {
  303. this.$refs.zhe.close();
  304. },
  305. closeCount() {
  306. this.$refs.number.close();
  307. },
  308. closeImg(){
  309. this.$refs.img.close();
  310. },
  311. close() {
  312. this.$refs.order.close();
  313. },
  314. handleShow(index, type, item){
  315. if(type){
  316. this.newList.forEach((item, count) =>{
  317. if(item.index === index){
  318. this.newList.splice(count,1);
  319. }
  320. })
  321. }else{
  322. this.newList.push({
  323. ...item,
  324. index: index,
  325. all: item.goodsRatePrice*(item.goodsPrice || 1),
  326. num: 1,
  327. })
  328. }
  329. this.total =null;
  330. this.yuan = null;
  331. this.newList.forEach(item =>{
  332. this.total += parseFloat(item.all);
  333. this.yuan += parseFloat(item.goodsRatePrice);
  334. })
  335. this.youhuiTotal = this.total;
  336. this.list[index].show = !this.list[index].show
  337. },
  338. // 预览图片
  339. preAvatar(url) {
  340. wx.previewImage({
  341. current: url, // 当前显示图片的 http 链接
  342. urls: [url] ,// 需要预览的图片 http 链接列表
  343. })
  344. },
  345. image(e) {
  346. return http.webUrl + e
  347. },
  348. getListFn(id){
  349. server.getGoodsInfo({shopsId: id, goodsStatus :'2'}).then(res =>{
  350. this.list = [];
  351. if(res){
  352. res.forEach(item =>{
  353. this.list.push({
  354. ...item,
  355. show: false,
  356. })
  357. })
  358. }
  359. })
  360. },
  361. }
  362. }
  363. </script>
  364. <style lang="scss" scoped>
  365. .liet{
  366. padding: 30rpx;
  367. background: #fff;
  368. min-height: 100vh;
  369. }
  370. .title {
  371. display: flex;
  372. align-items: center;
  373. text-align: center;
  374. justify-content: flex-end;
  375. .close {
  376. width: 50rpx;
  377. height: 50rpx;
  378. }
  379. }
  380. .main{
  381. width: 100%;
  382. height: auto;
  383. min-height: 100vh;
  384. padding: 30rpx;
  385. .other{
  386. width: 100%;
  387. height: 100rpx;
  388. margin-bottom: 30rpx;
  389. background-color: #fff;
  390. text-align: center;
  391. border-radius: 8rpx;
  392. line-height: 100rpx;
  393. font-size: 32rpx;
  394. font-weight: 600;
  395. letter-spacing: 2rpx;
  396. }
  397. .view-list{
  398. display: flex;
  399. flex-direction: row;
  400. justify-content: space-between;
  401. flex-wrap: wrap;
  402. margin-bottom: 100rpx;
  403. .item{
  404. width: calc(50% - 15rpx);
  405. height: 490rpx;
  406. background: #fff;
  407. border-radius: 8rpx;
  408. margin-bottom: 30rpx;
  409. image{
  410. width: 100%;
  411. height: 228rpx;
  412. border-top-right-radius: 8rpx;
  413. border-top-left-radius: 8rpx;
  414. }
  415. .item-footer{
  416. padding: 10rpx 20rpx 0rpx 20rpx;
  417. position: relative;
  418. .icon{
  419. position: absolute;
  420. bottom: 0rpx;
  421. right: 20rpx;
  422. }
  423. }
  424. }
  425. }
  426. }
  427. .footer1{
  428. width: 100%;
  429. height: 125rpx;
  430. background: #FFFFFF;
  431. position: -webkit-sticky;
  432. position: sticky;
  433. bottom: 0;
  434. left: 0rpx;
  435. bottom: 0rpx;
  436. padding: 14rpx 30rpx;
  437. display: flex;
  438. justify-content: space-between;
  439. z-index: 10;
  440. .total{
  441. height: 96rpx;
  442. line-height: 96rpx;
  443. font-weight: 600;
  444. }
  445. .left{
  446. width: 180rpx;
  447. height: 96rpx;
  448. line-height: 96rpx;
  449. border-radius: 48rpx;
  450. text-align: center;
  451. }
  452. .right{
  453. width: 180rpx;
  454. height: 96rpx;
  455. line-height: 96rpx;
  456. border-radius: 48rpx;
  457. text-align: center;
  458. border: 4rpx solid #2E4F1C;
  459. }
  460. }
  461. .right1{
  462. width: 570rpx;
  463. height: 96rpx;
  464. background: linear-gradient(117deg, #5B873C 0%, #2E4F1C 100%);
  465. border-radius: 49rpx;
  466. font-size: 36rpx;
  467. font-family: PingFangSC-Medium, PingFang SC;
  468. font-weight: 500;
  469. color: #fff;
  470. text-align: center;
  471. line-height: 96rpx;
  472. margin: 90rpx auto;
  473. }
  474. .footer{
  475. width: 100%;
  476. height: 125rpx;
  477. background: #FFFFFF;
  478. position: fixed;
  479. left: 0rpx;
  480. bottom: 0rpx;
  481. padding: 14rpx 30rpx;
  482. display: flex;
  483. justify-content: space-between;
  484. z-index: 10;
  485. .left{
  486. width: 330rpx;
  487. height: 96rpx;
  488. line-height: 96rpx;
  489. border-radius: 48rpx;
  490. text-align: center;
  491. }
  492. .right{
  493. width: 330rpx;
  494. height: 96rpx;
  495. line-height: 96rpx;
  496. border-radius: 48rpx;
  497. text-align: center;
  498. border: 4rpx solid #2E4F1C;
  499. }
  500. }
  501. /deep/ .product-window{
  502. position: fixed!important;
  503. background-color: #F8F8F8!important;
  504. padding: 0rpx!important;
  505. z-index: 77!important;
  506. transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9)!important;
  507. -webkit-transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9)!important;
  508. }
  509. .order-list{
  510. position: relative;
  511. padding: 30rpx 30rpx 0rpx 30rpx;
  512. // overflow: scroll;
  513. min-height: 100vh;
  514. // height: auto;
  515. .order-item{
  516. width: 100%;
  517. height: 341rpx;
  518. background: #fff;
  519. margin-bottom: 30rpx;
  520. border-radius: 8rpx;
  521. .order-item-header{
  522. height: 238rpx;
  523. display: flex;
  524. border-bottom: 2rpx solid #CCCCCC;
  525. image{
  526. width: 238rpx;
  527. height: 238rpx;
  528. background: #D8D8D8;
  529. }
  530. .order-item-header-right{
  531. padding-left: 20rpx;
  532. padding-top: 8rpx;
  533. }
  534. }
  535. .order-item-footer{
  536. text-align: right;
  537. height: 101rpx;
  538. line-height: 101rpx;
  539. padding-right: 30rpx;
  540. }
  541. }
  542. }
  543. .name{
  544. color: #000000;
  545. }
  546. .yuan{
  547. padding-top: 20rpx;
  548. }
  549. </style>