shopping_car.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <view class="page">
  3. <!-- 购物车 -->
  4. <u-navbar title="购物车" :background="background" title-color="#ffffff" back-icon-color="#ffffff" is-fixed>
  5. <template slot="right">
  6. <text class="navbar-button" v-show="enbleEdit==false" @click="enbleEdit=true">编辑</text>
  7. <text class="navbar-button" v-show="enbleEdit==true" @click="enbleEdit=false">完成</text>
  8. </template>
  9. </u-navbar>
  10. <u-checkbox-group class="order" @change="checkboxGroupChange">
  11. <u-checkbox @change="checkboxChange" style="width: 100%;" v-model="item.checked" shape="circle" v-for="(item,index) in goodsList" :key="item.id" :name="item.id">
  12. <view class="item">
  13. <view class="left">
  14. <image :src="item.goodsUrl" mode="aspectFill"></image>
  15. </view>
  16. <view class="content">
  17. <view class="title u-line-2">{{ item.title }}</view>
  18. <view class="type">{{ item.type }}</view>
  19. <!-- <view class="delivery-time">发货时间 {{ item.deliveryTime }}</view> -->
  20. <view class="price-row">
  21. <view class="brand">
  22. {{ item.brand }}
  23. </view>
  24. <view class="demo-count-box">
  25. <u-number-box v-model="selectedCount" :min="1" @change="selectedCountChange"></u-number-box>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </u-checkbox>
  31. </u-checkbox-group>
  32. <u-loadmore :status="loadStatus" bgColor="#f2f2f2"></u-loadmore>
  33. <view class="navigation">
  34. <view class="left">
  35. <view class="item">
  36. <u-checkbox shape="circle" @change="checkedAll" v-model="checkedAllValue">全选</u-checkbox>
  37. </view>
  38. </view>
  39. <view class="right" v-show="enbleEdit==false">
  40. <view class="total">合计:<text>2条</text></view>
  41. <view class="buy btn u-line-1" @click="handleSubmit">立即下单</view>
  42. </view>
  43. <view class="right" v-show="enbleEdit==true">
  44. <view class="buy btn u-line-1" @click="handleDel">删除</view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. background: {
  54. backgroundColor: "#0291FD",
  55. color: "#ffffff"
  56. },
  57. buttonCustomStyle: {
  58. color: "#ffffff",
  59. background: "transparent",
  60. border: "none"
  61. },
  62. selectedCount: 0,
  63. checkedAllValue: false,
  64. enbleEdit: false,
  65. loadStatus: "false",
  66. goodsList: [],
  67. list: [{
  68. id: "1",
  69. goodsUrl: 'https://img12.360buyimg.com/n7/jfs/t16642/126/2693663818/450163/6879e8ce/5b06d93bN6305bd94.png',
  70. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  71. type: '胎动品牌;修补类型;普通积分',
  72. deliveryTime: '付款后30天内发货',
  73. price: '348.58',
  74. number: 2,
  75. checked: false,
  76. disabled: false,
  77. brand: "SAILUN"
  78. },
  79. {
  80. id: "2",
  81. goodsUrl: 'https://img12.360buyimg.com/n7/jfs/t1/47645/22/6120/140457/5d3d17deEec9f8e8d/3687ff03ca89b48c.jpg',
  82. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  83. type: '胎动品牌;修补类型;普通积分',
  84. deliveryTime: '付款后30天内发货',
  85. price: '135.00',
  86. number: 1,
  87. checked: false,
  88. disabled: false,
  89. brand: "SAILUN"
  90. },
  91. {
  92. id: "3",
  93. goodsUrl: 'https://img11.360buyimg.com/n7/jfs/t1/88990/24/4208/105799/5de4c6e9E24bc09d0/f810effb14c9c13a.jpg',
  94. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  95. type: '胎动品牌;修补类型;普通积分',
  96. deliveryTime: '付款后7天内发货',
  97. price: '128.05',
  98. number: 1,
  99. checked: false,
  100. disabled: false,
  101. brand: "SAILUN"
  102. },
  103. {
  104. id: "4",
  105. goodsUrl: 'https://img12.360buyimg.com/n7/jfs/t1/93698/23/4500/114562/5de713dfEfc997085/e8deaa979909851d.jpg',
  106. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  107. type: '胎动品牌;修补类型;普通积分',
  108. deliveryTime: '保质5年',
  109. price: '1998',
  110. number: 3,
  111. checked: false,
  112. disabled: false,
  113. brand: "SAILUN"
  114. },
  115. {
  116. id: "5",
  117. goodsUrl: 'https://img11.360buyimg.com/n7/jfs/t16642/126/2693663818/450163/6879e8ce/5b06d93bN6305bd94.png',
  118. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  119. type: '胎动品牌;修补类型;普通积分',
  120. deliveryTime: '保质5年',
  121. price: '2354',
  122. number: 1,
  123. checked: false,
  124. disabled: false,
  125. brand: "SAILUN"
  126. },
  127. {
  128. id: "6",
  129. goodsUrl: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  130. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  131. type: '胎动品牌;修补类型;普通积分',
  132. deliveryTime: '珍藏10年好酒',
  133. price: '1543',
  134. number: 3,
  135. checked: false,
  136. disabled: false,
  137. brand: "SAILUN"
  138. },
  139. {
  140. id: "7",
  141. goodsUrl: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  142. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  143. type: '胎动品牌;修补类型;普通积分',
  144. deliveryTime: '口感好',
  145. price: '120',
  146. number: 1,
  147. checked: false,
  148. disabled: false,
  149. brand: "SAILUN"
  150. },
  151. {
  152. id: "8",
  153. goodsUrl: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  154. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  155. type: '胎动品牌;修补类型;普通积分',
  156. deliveryTime: '使用方便',
  157. price: '451',
  158. number: 9,
  159. checked: false,
  160. disabled: false,
  161. brand: "SAILUN"
  162. }
  163. ]
  164. }
  165. },
  166. onLoad() {
  167. this.addRandomData();
  168. },
  169. onReachBottom() {
  170. this.loadStatus = 'loading';
  171. // 模拟数据加载
  172. setTimeout(() => {
  173. this.addRandomData();
  174. this.loadStatus = 'loadmore';
  175. }, 1000)
  176. },
  177. methods: {
  178. selectedCountChange: function(){},
  179. checkboxGroupChange: function(params) {
  180. console.log(1)
  181. console.log(params)
  182. },
  183. checkboxChange: function(params) {
  184. if(!params.value){
  185. this.checkedAllValue = false;
  186. }
  187. },
  188. checkedAll: function(params) {
  189. console.log(this.checkedAllValue)
  190. if(params.value){
  191. this.list.map(val => {
  192. val.checked = true;
  193. })
  194. }else{
  195. this.list.map(val => {
  196. val.checked = false;
  197. })
  198. }
  199. },
  200. handleSubmit: function(){},
  201. handleDel: function(){},
  202. addRandomData() {
  203. for (let i = 0; i < 10; i++) {
  204. let index = this.$u.random(0, this.list.length - 1);
  205. // 先转成字符串再转成对象,避免数组对象引用导致数据混乱
  206. let item = JSON.parse(JSON.stringify(this.list[index]))
  207. item.id = this.$u.guid();
  208. this.goodsList.push(item);
  209. }
  210. },
  211. }
  212. }
  213. </script>
  214. <style lang="scss" scoped>
  215. .page{
  216. padding-bottom: 100rpx;
  217. }
  218. .navbar-button {
  219. padding: 24rpx 26rpx;
  220. display: inline-block;
  221. }
  222. .order {
  223. width: 710rpx;
  224. background-color: #ffffff;
  225. margin: 20rpx auto;
  226. border-radius: 20rpx;
  227. box-sizing: content-box;
  228. padding: 20rpx;
  229. font-size: 28rpx;
  230. .top {
  231. display: flex;
  232. justify-content: space-between;
  233. .left {
  234. display: flex;
  235. align-items: center;
  236. .store {
  237. margin: 0 10rpx;
  238. font-size: 32rpx;
  239. font-weight: bold;
  240. }
  241. }
  242. .right {
  243. color: $u-type-warning-dark;
  244. }
  245. }
  246. .item {
  247. display: flex;
  248. margin: 20rpx 0 0;
  249. .left {
  250. margin-right: 20rpx;
  251. image {
  252. width: 200rpx;
  253. height: 200rpx;
  254. border-radius: 10rpx;
  255. }
  256. }
  257. .content {
  258. .title {
  259. font-size: 28rpx;
  260. line-height: 50rpx;
  261. }
  262. .type {
  263. margin: 10rpx 0;
  264. font-size: 24rpx;
  265. color: $u-tips-color;
  266. }
  267. .delivery-time {
  268. color: #e5d001;
  269. font-size: 24rpx;
  270. }
  271. .price-row {
  272. display: flex;
  273. justify-content: space-between;
  274. margin: 10rpx 0;
  275. font-size: 26rpx;
  276. .price {
  277. color: #FF0000;
  278. }
  279. .brand{
  280. color: #999999;
  281. background: #F3F3F3;
  282. padding: 0 8rpx;
  283. border-radius: 5rpx;
  284. }
  285. .exchange {
  286. background: #0094FE;
  287. color: #FFFFFF;
  288. padding: 4rpx 16rpx;
  289. line-height: 1.5;
  290. }
  291. }
  292. }
  293. .right {
  294. margin-left: 10rpx;
  295. padding-top: 20rpx;
  296. text-align: right;
  297. .decimal {
  298. font-size: 24rpx;
  299. margin-top: 4rpx;
  300. }
  301. .number {
  302. color: $u-tips-color;
  303. font-size: 24rpx;
  304. }
  305. }
  306. }
  307. .total {
  308. margin-top: 20rpx;
  309. text-align: right;
  310. font-size: 24rpx;
  311. .total-price {
  312. font-size: 32rpx;
  313. }
  314. }
  315. .bottom {
  316. display: flex;
  317. margin-top: 40rpx;
  318. padding: 0 10rpx;
  319. justify-content: space-between;
  320. align-items: center;
  321. .btn {
  322. line-height: 52rpx;
  323. width: 160rpx;
  324. border-radius: 26rpx;
  325. border: 2rpx solid $u-border-color;
  326. font-size: 26rpx;
  327. text-align: center;
  328. color: $u-type-info-dark;
  329. }
  330. .evaluate {
  331. color: $u-type-warning-dark;
  332. border-color: $u-type-warning-dark;
  333. }
  334. }
  335. }
  336. .navigation {
  337. display: flex;
  338. width: 100%;
  339. justify-content: space-between;
  340. margin-top: 100rpx;
  341. border: solid 2rpx #f2f2f2;
  342. background-color: #ffffff;
  343. padding: 16rpx 0;
  344. position: fixed;
  345. bottom: 0;
  346. z-index: 100;
  347. .left {
  348. display: flex;
  349. font-size: 20rpx;
  350. .item {
  351. margin: 0 30rpx;
  352. &.car {
  353. text-align: center;
  354. position: relative;
  355. .car-num {
  356. position: absolute;
  357. top: -10rpx;
  358. right: -10rpx;
  359. }
  360. }
  361. }
  362. }
  363. .right {
  364. display: flex;
  365. font-size: 28rpx;
  366. align-items: center;
  367. .btn {
  368. line-height: 66rpx;
  369. padding: 0 30rpx;
  370. border-radius: 36rpx;
  371. color: #ffffff;
  372. }
  373. .cart {
  374. background-color: #ed3f14;
  375. margin-right: 30rpx;
  376. }
  377. .buy {
  378. margin: 0 16rpx;
  379. background-color: #ff7900;
  380. }
  381. }
  382. }
  383. </style>