preOrder.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <view style="overflow: hidden;">
  3. <view class="wrapper">
  4. <view class="address" @click="selectAddress">
  5. <view class="left">
  6. <view class="icon">
  7. <u-icon color="#ff536f" name="map" size="38"></u-icon>
  8. </view>
  9. <view class="title">
  10. <view class="name">
  11. {{ mallOrder.receiverAddress }}
  12. </view>
  13. <view class="desc">
  14. {{ mallOrder.receiver }} {{ mallOrder.receiverPhone }}
  15. </view>
  16. </view>
  17. </view>
  18. <view class="right">
  19. <u-icon color="#ddd" name="arrow-right" size="30"></u-icon>
  20. </view>
  21. <image class="lineImg" mode="widthFix" src="../../static/icon/addr-line.png"></image>
  22. </view>
  23. </view>
  24. <!-- 商品信息 -->
  25. <view class="wrapper">
  26. <view class="goods">
  27. <u-read-more :shadow-style="shadowStyle" close-text="查看更多" color="#909399" show-height="400" text-indent="0"
  28. toggle>
  29. <view v-for="(item,index) in goodsList" v-if="item.check" :key="index"
  30. class="product">
  31. <view>
  32. <image :src="item.image" mode="widthFix" style="width: 150rpx;height: 150rpx;"></image>
  33. </view>
  34. <view class="right">
  35. <view class="item-title">{{ item.title }}</view>
  36. <view class="item-bottom">
  37. <view class="item-price">
  38. <view class="new-price">¥{{ item.price }} x {{ item.value }}</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </u-read-more>
  44. <view class="items"></view>
  45. <view class="info">
  46. <view class="cell-list">
  47. <view class="cell" @click="code">
  48. <view class="left">
  49. <text>商品金额</text>
  50. </view>
  51. <view class="right" style="color:#303133 ;">
  52. ¥{{ totalPrice }}
  53. </view>
  54. </view>
  55. <!-- <view class="cell" @click="code">
  56. <view class="left">
  57. <text class="text" style="
  58. padding: 6rpx 8rpx;
  59. margin-right: 8rpx;
  60. font-size: 20rpx;
  61. color: #fff;
  62. border-radius: 8rpx;
  63. background-color: orange;
  64. ">满</text>
  65. <text class="text">订单满减</text>
  66. </view>
  67. <view class="right" style="color:#303133 ;">
  68. -¥30
  69. </view>
  70. </view> -->
  71. <!-- <view class="cell" @click="code">
  72. <view class="left">
  73. <text class="text" style="
  74. padding: 6rpx 8rpx;
  75. margin-right: 8rpx;
  76. font-size: 20rpx;
  77. color: #fff;
  78. border-radius: 8rpx;
  79. background-color: #ff536f;
  80. ">卷</text>
  81. <text class="text">优惠卷</text>
  82. </view>
  83. <view class="right">
  84. 暂无可用
  85. </view>
  86. </view> -->
  87. <!-- <view class="cell" @click="code">
  88. <view class="left">
  89. <text class="text">配送费</text>
  90. </view>
  91. <view class="right" style="color: #303133 ">
  92. -¥0
  93. </view>
  94. </view> -->
  95. </view>
  96. </view>
  97. <view class="price">
  98. 应付:¥{{ totalPrice }}
  99. </view>
  100. </view>
  101. </view>
  102. <view class="wrapper wrapper-bottom">
  103. <view class="remark">
  104. <view class="title">
  105. 订单备注:
  106. </view>
  107. <view class="textArea">
  108. <u-input v-model="mallOrder.remark" :auto-height="autoHeight" :border="border" :height="height" :type="type"
  109. placeholder="选填 , 合理需求我们会尽量满足..."/>
  110. </view>
  111. </view>
  112. </view>
  113. <view class="bottomView">
  114. <view class="bottomLeft" @click="checkGoods">
  115. <view class="clear">
  116. 实付款:
  117. </view>
  118. <view class="left">
  119. ¥{{ totalPrice }}
  120. </view>
  121. </view>
  122. <view class="bottomRight">
  123. <view class="right" @click="subOrder">
  124. 提交订单
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. </template>
  130. <script>
  131. import config from "@/common/config.js" // 全局配置文件
  132. export default {
  133. data() {
  134. return {
  135. type: 'textarea',
  136. border: false,
  137. height: 100,
  138. autoHeight: true,
  139. shadowStyle: {
  140. backgroundImage: "none",
  141. paddingTop: "20rpx",
  142. },
  143. goodsList: [],
  144. totalPrice: 0,
  145. mallOrder: {
  146. receiver: '',
  147. receiverPhone: '',
  148. receiverAddress: '',
  149. payAmount: 0,
  150. payStatus: 1,
  151. disAmount: 0,
  152. orderStatus: 1,
  153. remark: '',
  154. mallOrderGoodsList: []
  155. },
  156. }
  157. },
  158. onLoad(option) {
  159. // 检查token
  160. this.checkToken();
  161. if (option.addressId) {
  162. this.mallOrder.receiverAddress = option.addressName
  163. this.mallOrder.receiverPhone = option.phone
  164. this.mallOrder.receiver = option.userName
  165. } else {
  166. // 设置默认收货地址
  167. this.setDefaultAddress()
  168. }
  169. // 商品列表
  170. this.goodsList = this.vuex_cartList.reverse()
  171. // 计算价格
  172. this.goodsList.map((val, idx) => {
  173. if (this.goodsList[idx].check) {
  174. this.totalPrice = this.totalPrice + this.goodsList[idx].value * this.goodsList[idx].price
  175. }
  176. })
  177. this.mallOrder.payAmount = this.totalPrice
  178. },
  179. methods: {
  180. checkToken() {
  181. // 判断Token是否有效
  182. let lifeData = uni.getStorageSync('lifeData');
  183. let token = lifeData.vuex_token
  184. if (!token) {
  185. // 没有token 则跳转到登录
  186. return uni.reLaunch({
  187. url: '../login/login'
  188. })
  189. } else {
  190. this.myavatar = config.baseUrl + uni.getStorageSync('lifeData').vuex_user.user.avatar
  191. }
  192. },
  193. subOrder() {
  194. if (!this.mallOrder.receiverAddress) {
  195. return this.$mytip.toast('请选择收货地址')
  196. }
  197. this.mallOrder.mallOrderGoodsList = this.goodsList
  198. let url = "/api/mallApi/insertMallOrder"
  199. this.$u.post(url, this.mallOrder).then(result => {
  200. this.$u.route('/pages/order/order')
  201. });
  202. },
  203. selectAddress() {
  204. this.$u.route('/pages/address/address')
  205. },
  206. setDefaultAddress() {
  207. let url = "/api/mallApi/findAddressList";
  208. this.$u.get(url, {
  209. orderByColumn: 'create_time',
  210. isAsc: 'desc',
  211. pageNum: 1,
  212. pageSize: 100,
  213. isDefault: 1
  214. }).then(result => {
  215. // 商品数据
  216. let defaultAddress = result.rows[0];
  217. this.mallOrder.receiverAddress = defaultAddress.address
  218. this.mallOrder.receiverPhone = defaultAddress.phone
  219. this.mallOrder.receiver = defaultAddress.userName
  220. });
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss">
  226. .wrapper {
  227. margin: 20 rpx 20 rpx 10 rpx 20 rpx;
  228. background-color: #fff;
  229. padding: 20 rpx 20 rpx 20 rpx 20 rpx;
  230. border-radius: 3px;
  231. // color: $u-main-color;
  232. color: $u-tips-color;
  233. .address {
  234. margin: 10 rpx 0;
  235. display: flex;
  236. justify-content: space-between;
  237. position: relative;
  238. .left {
  239. display: flex;
  240. align-items: center;
  241. .title {
  242. margin-left: 10 rpx;
  243. .name {
  244. font-size: 14px;
  245. font-weight: 600;
  246. color: $u-main-color;
  247. }
  248. .desc {
  249. font-size: 14px;
  250. }
  251. }
  252. }
  253. .right {
  254. position: absolute;
  255. right: 0;
  256. }
  257. .lineImg {
  258. width: 710 rpx;
  259. position: absolute;
  260. bottom: -30rpx;
  261. left: -20rpx;
  262. }
  263. }
  264. .goods {
  265. color: $u-main-color;
  266. .product {
  267. display: flex;
  268. margin-bottom: 30 rpx;
  269. border-bottom: 1px solid #eee;
  270. &:last-child {
  271. border-bottom: 0;
  272. }
  273. .right {
  274. margin-left: 20 rpx;
  275. .item-title {
  276. font-size: 14px;
  277. color: $u-main-color;
  278. font-weight: bold;
  279. padding-top: 10 rpx;
  280. padding-left: 10 rpx;
  281. background-color: #fff;
  282. }
  283. .item-bottom {
  284. margin-top: 20 rpx;
  285. background-color: #fff;
  286. display: flex;
  287. align-items: center;
  288. .item-price {
  289. display: flex;
  290. align-items: center;
  291. width: 250 rpx;
  292. max-width: 250 rpx;
  293. text-overflow: ellipsis;
  294. overflow: hidden;
  295. white-space: nowrap;
  296. .new-price {
  297. font-weight: normal;
  298. font-size: 14px;
  299. color: $u-main-color;
  300. padding: 5px 0 5px 2px;
  301. }
  302. }
  303. }
  304. .item-desc {
  305. font-weight: normal;
  306. font-size: 26 rpx;
  307. color: $u-tips-color;
  308. padding-bottom: 5 rpx;
  309. padding-left: 10 rpx;
  310. background-color: #fff;
  311. }
  312. }
  313. }
  314. .info {
  315. .cell-list {
  316. background-color: #fff;
  317. .cell {
  318. margin-bottom: 30 rpx;
  319. display: flex;
  320. justify-content: space-between;
  321. align-items: center;
  322. .left {
  323. display: flex;
  324. justify-content: space-between;
  325. align-items: center;
  326. color: $u-main-color;
  327. font-size: 30 rpx;
  328. .text {
  329. padding-left: 10 rpx;
  330. }
  331. }
  332. .right {
  333. font-size: 28 rpx;
  334. color: $u-tips-color;
  335. }
  336. }
  337. }
  338. }
  339. .price {
  340. text-align: right;
  341. font-weight: 800;
  342. border-top: 1px solid #eee;
  343. padding-top: 20 rpx;
  344. }
  345. }
  346. .remark {
  347. .title {
  348. color: $u-main-color;
  349. font-weight: 800;
  350. }
  351. .textArea {
  352. margin-top: 20 rpx;
  353. }
  354. }
  355. }
  356. .wrapper-bottom {
  357. margin-bottom: 120 rpx;
  358. }
  359. .bottomView {
  360. box-shadow: 0 -1px 1px 0 rgba(0, 0, 0, 0.05);
  361. position: fixed;
  362. left: 0;
  363. right: 0;
  364. bottom: 0;
  365. background-color: #ffffff;
  366. z-index: 999;
  367. height: 100 rpx;
  368. line-height: 100 rpx;
  369. display: flex;
  370. justify-content: space-between;
  371. align-items: center;
  372. padding: 20 rpx;
  373. .bottomLeft {
  374. display: flex;
  375. align-items: center;
  376. position: relative;
  377. height: 100 rpx;
  378. line-height: 100 rpx;
  379. .clear {
  380. text-align: center;
  381. border-radius: 10%;
  382. color: $u-tips-color;
  383. font-size: 14px;
  384. margin-right: 20 rpx;
  385. }
  386. .left {
  387. color: $base-color;
  388. font-size: 16px;
  389. font-weight: 800;
  390. }
  391. }
  392. .bottomRight {
  393. display: flex;
  394. align-items: center;
  395. height: 60 rpx;
  396. line-height: 60 rpx;
  397. .right {
  398. color: #fff;
  399. background: $base-color;
  400. padding: 2 rpx 20 rpx;
  401. border-radius: 30 rpx;
  402. margin-left: 20 rpx;
  403. }
  404. ;
  405. }
  406. }
  407. </style>