shoppingCart.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <view>
  3. <u-navbar :is-back="false" title="购物车" :border-bottom="false" title-color="#333333" back-icon-color="#ffffff">
  4. <view class="slot-wrap">
  5. <image src="/static/logo2.png" style="width: 178rpx;height: 31rpx;margin-left: 30rpx;"></image>
  6. </view>
  7. </u-navbar>
  8. <view v-show="isLogin">
  9. <view style="padding: 30rpx;padding-bottom: 98rpx;">
  10. <uni-swipe-action>
  11. <u-checkbox-group
  12. placement="column">
  13. <view>
  14. <uni-swipe-action-item :autoClose="false" @change="swipeChange($event, item)" :show="item.show" v-for="(item,index) in list" :key="index" >
  15. <view class="item">
  16. <view style="width: 100%;">
  17. <view style="display: flex;padding-bottom: 15rpx;">
  18. <view style="display: flex;align-items:center;">
  19. <u-checkbox
  20. @change="checkboxChange"
  21. v-model="list[index].checked"
  22. shape="circle"
  23. :name="index">
  24. </u-checkbox>
  25. </view>
  26. <view>
  27. <image :src="$method.splitImgHost(item.coverUrl, true)" style="width: 278rpx;height: 134rpx;"></image>
  28. </view>
  29. <view style="margin-left: 20rpx;flex: 1;">
  30. <view style="color: #333333;font-size: 30rpx;font-weight: bold;">
  31. {{item.goodsName}}
  32. </view>
  33. <view class="priceTag">
  34. ¥ {{item.standPrice}}
  35. </view>
  36. </view>
  37. </view>
  38. <u-line color="#D6D6DB" />
  39. <view style="display: flex;justify-content: space-between;align-items: center;height: 50rpx;" @click="openPopup(index)">
  40. <view style="color: #666666;font-size: 24rpx;margin-left: 60rpx;">选择班级</view>
  41. <view><u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
  42. </view>
  43. </view>
  44. </view>
  45. <template v-slot:right>
  46. <view class="operate" @click="delItem(item)">
  47. <view ><text>删除</text></view>
  48. </view>
  49. </template>
  50. </uni-swipe-action-item>
  51. </view>
  52. </u-checkbox-group>
  53. </uni-swipe-action>
  54. </view>
  55. <view class="bottomBox">
  56. <view>
  57. <u-checkbox
  58. label="all"
  59. name="all"
  60. shape="circle"
  61. @change="checkboxAllChange"
  62. v-model="allChecked"
  63. >
  64. </u-checkbox>
  65. <text>全选</text>
  66. </view>
  67. <view style="display: flex;align-items: center;">
  68. <view style="color: #999999;margin-right: 8rpx;">合计</view>
  69. <view class="priceTag">¥ {{totalPrice}}</view>
  70. <view style="display: flex;color: #FFFFFF;align-items: center;">
  71. <view class="btn2" @click="goBuy()">结算</view>
  72. </view>
  73. </view>
  74. </view>
  75. <u-popup v-model="show" mode="bottom"border-radius="40">
  76. <view class="popup_box">
  77. <view style="margin-bottom: 20rpx;">
  78. <view class="line1"></view>
  79. <view class="grade">选择班级</view>
  80. </view>
  81. <u-line color="#D6D6DB" />
  82. <view>
  83. <scroll-view scroll-y="true" style="height: 500rpx;">
  84. <view>
  85. <u-checkbox-group @change="checkboxGroupChange1">
  86. <view v-for="(item, index) in list" :key="index" >
  87. <view style="display: flex;align-items: center;padding: 20rpx;">
  88. <view>
  89. <u-checkbox
  90. shape="circle"
  91. @change="checkboxChange1"
  92. v-model="item.checked"
  93. :name="item.name"
  94. ></u-checkbox>
  95. </view>
  96. <view :class="item.checked?'white-box blue-box':'white-box'" >
  97. <view>
  98. <view class="blackTxt">2021年第1期二级建造师继续教育选修课(市政)标题过长换行显示</view>
  99. <view class="redTxt">有效期至:2021/11/30</view>
  100. <view class="redTxt">本班还剩41天将结束学习</view>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </u-checkbox-group>
  106. </view>
  107. </scroll-view>
  108. </view>
  109. <view class="confrim-btn">
  110. <view class="okBtn">确定</view>
  111. </view>
  112. </view>
  113. </u-popup>
  114. <u-popup v-model="show1" mode="bottom"border-radius="40">
  115. <view class="popup_box">
  116. <view style="margin-bottom: 20rpx;">
  117. <view class="line1"></view>
  118. <view class="grade">选择考期/地区</view>
  119. </view>
  120. <u-line color="#D6D6DB" />
  121. <view style="display: flex;height: 500rpx;">
  122. <view style="width: 50%;">
  123. <view class="topTxt">考期</view>
  124. <view>
  125. <picker-view :indicator-style="indicatorStyle" :value="value" @change="bindChange" class="picker-view">
  126. <picker-view-column>
  127. <view class="picker-item" v-for="(item,index) in list1" :key="index">{{item.label}}</view>
  128. </picker-view-column>
  129. </picker-view>
  130. </view>
  131. </view>
  132. <view style="width: 50%;">
  133. <view class="topTxt">地区</view>
  134. <view>
  135. <picker-view :indicator-style="indicatorStyle" :value="value" @change="bindChange" class="picker-view">
  136. <picker-view-column>
  137. <view class="picker-item" v-for="(item,index) in list2" :key="index">{{item.label}}</view>
  138. </picker-view-column>
  139. <picker-view-column>
  140. <view class="picker-item" v-for="(item,index) in list3" :key="index">{{item.label}}</view>
  141. </picker-view-column>
  142. </picker-view>
  143. </view>
  144. </view>
  145. </view>
  146. <view class="confrim-btn">
  147. <view class="okBtn">确定</view>
  148. </view>
  149. </view>
  150. </u-popup>
  151. </view>
  152. <view v-show="!isLogin">
  153. <view style="display: flex;align-items:center;flex-direction: column;margin-top: 40%;font-size: 32rpx;">
  154. <view style="color: #999999;">您还没有登录哦~</view>
  155. <view style="margin-top: 30rpx;" ><u-button type="primary" @click="login">去登录</u-button></view>
  156. </view>
  157. </view>
  158. </view>
  159. </template>
  160. <script>
  161. export default {
  162. data() {
  163. return {
  164. isLogin:false,
  165. allChecked:false,
  166. checkboxValue1:[],
  167. list: [
  168. ],
  169. list1:[
  170. {
  171. value: '1',
  172. label: '2021年6月'
  173. },
  174. {
  175. value: '2',
  176. label: '2021年7月'
  177. }
  178. ],
  179. list1:[
  180. {
  181. value: '1',
  182. label: '2021年6月'
  183. },
  184. {
  185. value: '2',
  186. label: '2021年7月'
  187. },
  188. {
  189. value: '3',
  190. label: '2021年8月'
  191. },
  192. {
  193. value: '4',
  194. label: '2021年9月'
  195. }
  196. ],
  197. list2:[
  198. {
  199. value: '1',
  200. label: '广东'
  201. },
  202. {
  203. value: '2',
  204. label: '北京'
  205. }
  206. ],
  207. list3:[
  208. {
  209. value: '1',
  210. label: '广州'
  211. },
  212. {
  213. value: '2',
  214. label: '深圳'
  215. }
  216. ],
  217. value1:'',
  218. show:false,
  219. show1:false,
  220. totalPrice:0.00,
  221. isOld:false
  222. }
  223. },
  224. onLoad(option) {
  225. },
  226. onShow() {
  227. this.isLogin = this.$method.isLogin()
  228. if(this.isLogin){
  229. if(uni.getStorageSync('updateCart')||!this.isOld){
  230. this.isOld = true
  231. this.cartList()
  232. uni.removeStorageSync('updateCart')//消费购物车刷新事件
  233. }
  234. }
  235. },
  236. methods: {
  237. countPrice(list){
  238. },
  239. checkboxChange1(e) {
  240. //console.log(e);
  241. },
  242. login(){
  243. uni.navigateTo({url:'/pages/login/login'});
  244. },
  245. cartList() {
  246. let self = this
  247. this.allChecked = false
  248. this.totalPrice = 0.00
  249. this.$api.cartList().then(res => {
  250. if(res.data.code==200){
  251. for (let i = 0; i < res.data.rows.length; i++) {
  252. let item = res.data.rows[i]
  253. item.checked = false
  254. if(item.status!=1||item.goodsStatus!=1){
  255. item.disabled = true
  256. }else{
  257. item.disabled = false
  258. }
  259. item.show = false
  260. }
  261. self.list = res.data.rows
  262. }
  263. });
  264. },
  265. delItem(item) {
  266. let self = this
  267. this.$api.deleteCart(item.id).then(res => {
  268. if(res.data.code==200){
  269. self.cartList()
  270. }
  271. });
  272. },
  273. swipeChange(e, item) {
  274. item.show = e;
  275. },
  276. goBuy(){
  277. this.$navTo.togo('/pages2/order/confirm_pay');
  278. },
  279. checkboxChange(n) {
  280. console.log('change', n);
  281. if(n.value){
  282. this.totalPrice += this.list[n.name].standPrice
  283. }else{
  284. this.totalPrice -= this.list[n.name].standPrice
  285. }
  286. },
  287. openPopup(index){
  288. if(index==0){
  289. this.show = true
  290. }else{
  291. this.show1 = true
  292. }
  293. },
  294. checkboxAllChange(n){
  295. this.totalPrice = 0.00
  296. if(n.value){
  297. for(let i =0;i<this.list.length;i++){
  298. this.list[i].checked = true
  299. this.totalPrice += this.list[i].standPrice
  300. }
  301. }else{
  302. for(let i =0;i<this.list.length;i++){
  303. this.list[i].checked = false
  304. }
  305. }
  306. }
  307. }
  308. }
  309. </script>
  310. <style >
  311. page{
  312. background-color: #EAEEF1;
  313. }
  314. </style>
  315. <style scoped>
  316. .operate{
  317. background-color: #FF3B30;
  318. color: #FFFFFF;
  319. border-top-right-radius: 16rpx;
  320. border-bottom-right-radius: 16rpx;
  321. margin-bottom: 20rpx;
  322. display: flex;
  323. align-items:center;
  324. justify-content:center;
  325. padding: 0 20rpx;
  326. }
  327. .picker-item {
  328. height: 50px;
  329. align-items: center;
  330. justify-content: center;
  331. text-align: center;
  332. }
  333. .picker-view {
  334. width: 100%;
  335. height: 420rpx;
  336. text-align: center;
  337. }
  338. .topTxt{
  339. font-size: 30rpx;
  340. color: #666666;
  341. text-align: center;
  342. padding: 20rpx 0;
  343. }
  344. .blackTxt{
  345. font-size: 30rpx;
  346. font-family: PingFang SC;
  347. font-weight: bold;
  348. color: #333333;
  349. }
  350. .redTxt{
  351. font-size: 30rpx;
  352. font-family: PingFang SC;
  353. color: #FF2D55;
  354. margin-top: 13rpx;
  355. }
  356. .blue-box{
  357. background: #EBF5FF;
  358. }
  359. .white-box{
  360. width: 646rpx;
  361. height: 220rpx;
  362. border-radius: 24rpx;
  363. align-items: center;
  364. display: flex;
  365. padding-left: 15rpx;
  366. }
  367. .okBtn{
  368. width: 200rpx;
  369. height: 64rpx;
  370. background: linear-gradient(0deg, #015EEA, #00C0FA);
  371. border-radius: 32rpx;
  372. color: #FFFFFF;
  373. text-align: center;
  374. line-height: 64rpx;
  375. }
  376. .confrim-btn{
  377. height: 98rpx;
  378. width: 100%;
  379. display: flex;
  380. align-items: center;
  381. justify-content:center;
  382. }
  383. .grade{
  384. height: 23rpx;
  385. font-size: 24rpx;
  386. color: #999999;
  387. margin: 0 auto;
  388. margin-top: 15rpx;
  389. text-align: center;
  390. }
  391. .line1{
  392. width: 80rpx;
  393. height: 8rpx;
  394. background: #999999;
  395. border-radius: 4rpx;
  396. margin: 0 auto;
  397. margin-top: 15rpx;
  398. }
  399. .popup_box {
  400. height: 700rpx;
  401. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  402. border-radius: 32rpx 32rpx 0rpx 0rpx;
  403. }
  404. .item{
  405. width: 100%;
  406. background: #FFFFFF;
  407. border-radius: 16rpx;
  408. margin-bottom: 20rpx;
  409. padding: 15rpx;
  410. display: flex;
  411. }
  412. .priceTag{
  413. font-size: 30rpx;
  414. font-family: PingFang SC;
  415. font-weight: bold;
  416. color: #FF2D55;
  417. display: flex;
  418. flex-direction: row-reverse;
  419. margin-right: 8rpx;
  420. }
  421. .btn2{
  422. width: 200rpx;
  423. height: 64rpx;
  424. background: linear-gradient(0deg, #015EEA, #00C0FA);
  425. border-radius: 32rpx;
  426. text-align: center;
  427. line-height: 64rpx;
  428. }
  429. .bottomBox{
  430. position: fixed;
  431. bottom: 0;
  432. width: 100%;
  433. left: 0;
  434. height:98rpx ;
  435. background-color: #FFFFFF;
  436. display: flex;
  437. justify-content: space-between;
  438. align-items: center;
  439. padding: 0 30rpx;
  440. }
  441. </style>