order.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <view>
  3. <view
  4. style="width: 690upx;height: 130upx;background: #FFFFFF;margin: 30upx; padding: 10upx;border-radius: 20upx;"
  5. @tap='goEditAddress' v-if="isExpress === 1">
  6. <view style="display: flex;margin: 10upx 0 0 20upx;">
  7. <image src="../../../../static/images/icon_address.png"
  8. style="width: 70upx; height: 70upx;margin-top: 10upx;"></image>
  9. <view style="margin-left: 20upx;width: 80%;" v-if="checkAddress">
  10. <view style="display: flex;align-items: center;">
  11. <view style="font-size: 32upx;color: #333333;">{{consignee}}</view>
  12. <view style="font-size: 28upx;color: #999999;margin-left: 10upx;">{{mobile}}</view>
  13. </view>
  14. <view v-if="consignee"
  15. style="margin-top: 10upx;font-size: 30upx;color: #333333;width: 90%; white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
  16. {{provinces}}{{detail}}
  17. </view>
  18. </view>
  19. <view v-if="checkAddress == false"
  20. style="margin-left: 20upx;width: 80%;margin-top: 25upx;color: #000000;">
  21. 暂无地址信息,请添加地址信息</view>
  22. <image src="../../../../static/images/icon_right.png"
  23. style="width: 17upx;height: 28upx;margin-top: 35upx;"></image>
  24. </view>
  25. </view>
  26. <view
  27. style="width: 690upx;height: max-content;background: #FFFFFF;margin: 30upx; padding: 10upx;border-radius: 20upx;">
  28. <view style="display: flex;padding: 20upx;">
  29. <image :src="attrValuecoverImg" style="width: 200upx; height: 200upx;"></image>
  30. <view style="width: 65%;margin-left: 20upx;">
  31. <view
  32. style="font-size: 28upx;color: #333333;height: 78upx;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;">
  33. {{title}}
  34. </view>
  35. <view style="display: flex;width: 100%;" v-if="checkString != ''">
  36. <view style="font-size: 24upx;color: #333333;margin-top: 25upx;">商品规格:</view>
  37. <view style="font-size: 24upx;color: #333333;margin-top: 25upx;margin-left: 15upx;">
  38. {{checkString}}
  39. </view>
  40. </view>
  41. <view style="display: flex;">
  42. <view
  43. :style="checkString != '' ? 'display: flex;width: 70%;margin-top: 10upx;' : 'display: flex;width: 70%;margin-top: 30upx;'">
  44. <view style="font-size: 30upx;color: #333333;margin-top: 25upx;">¥ {{money}}</view>
  45. <view style="font-size: 20upx;color: #666666;margin-top: 30upx;margin-left: 15upx;">
  46. x{{number}}</view>
  47. </view>
  48. <view v-if="isExpress === 1 && className === '' && checkString == '' "
  49. style="width:200upx;height: 60upx;display: flex;margin-top: 30upx;border-radius: 5upx;border:1px solid #E6E6E6;">
  50. <view
  51. style="border-right:1px solid #E6E6E6;width: 70upx;color: #999999;text-align: center;margin-top: 15upx;"
  52. @click="jian">-</view>
  53. <view
  54. style="width: 80upx;text-align: center;font-size: 24upx;color: #333333;margin-top: 15upx;">
  55. {{number}}
  56. </view>
  57. <view
  58. style="border-left:1px solid #E6E6E6;width: 70upx;color: #999999;text-align: center;margin-top: 15upx"
  59. @click="jia">+</view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view style="display: flex;padding: 20upx;">
  65. <view style="font-size: 30upx;color: #333333;width: 25%;">配送方式</view>
  66. <view style="font-size: 30upx;color: #000000;margin-left: 10upx;width: 40%;">
  67. <picker mode="selector" :range="WayList" @change="WaySel">
  68. <view v-if="sendName === '请选择配送方式'" style="color: #000000;">{{sendName}}</view>
  69. <view v-else>{{sendName}}</view>
  70. </picker>
  71. </view>
  72. </view>
  73. <view style="display: flex;padding: 20upx;" v-if="sendName === '快递'">
  74. <view style="font-size: 30upx;color: #333333;width: 25%;">快递</view>
  75. <view style="font-size: 30upx;color: #000000;margin-left: 10upx;width: 40%;">
  76. {{postagePrice == 0 ? '包邮' : postagePrice + '元'}}
  77. </view>
  78. </view>
  79. <!-- 领劵end -->
  80. <view style="display: flex;padding: 30upx 20upx;">
  81. <view style="font-size: 30upx;color: #333333;width: 25%;">订单备注</view>
  82. <input type="text" style="width: 70%;font-size: 30upx;color: #999999;margin-left: 10upx;"
  83. v-model="descrition" placeholder="选填" />
  84. </view>
  85. </view>
  86. <view style="display: flex;background-color: #FFFFFF;width: 100%;height: 100upx;position: fixed;bottom: 0upx;">
  87. <view style="display: flex;font-size: 28upx;color: #333333;padding: 25upx 0 10upx 20upx;width: 50%;">
  88. <view v-if="className != 'jifen'" style="font-size: 28upx;color: #333333;padding: 5upx 0 10upx 10upx;">
  89. 总金额:</view>
  90. <view v-if="className != 'jifen'" style="font-size: 40upx;color: #05C25C;padding: 0upx 0 10upx 10upx;">
  91. ¥{{price + postagePrice}}</view>
  92. <view v-if="className === 'jifen'" style="font-size: 40upx;color: #05C25C;padding: 0upx 0 10upx 10upx;">
  93. {{price}}
  94. <text style="font-size: 28rpx;">积分</text>
  95. </view>
  96. </view>
  97. <button
  98. style="background-color: #05C25C;width: 300upx;height: 70upx;font-size: 28upx;color: #FFFFFF;text-align: center;margin-top: 15upx;border-radius: 50upx;"
  99. @tap='goPay'>提交订单</button>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. export default {
  105. data() {
  106. return {
  107. sendName: '请选择配送方式',
  108. sendWay: 0,
  109. WayList: [],
  110. descrition: '',
  111. number: 1,
  112. money: 0,
  113. consignee: '',
  114. provinces: '',
  115. commissionPrice: 0,
  116. id: 0,
  117. price: 0,
  118. couponUserId: '',
  119. postagePrice: 0,
  120. postagePrices: 0,
  121. title: '',
  122. attrValuecoverImg: '',
  123. isExpress: 1,
  124. checkString: '',
  125. detail: '',
  126. skuId: 0,
  127. lessMoney: 0,
  128. maxNumber: 0,
  129. groupPinkId: '',
  130. mobile: '',
  131. jianMoney: 0,
  132. list: {},
  133. addressId: '',
  134. className: '',
  135. userByinvitationId: '',
  136. checkAddress: false
  137. }
  138. },
  139. onShow() {
  140. this.addressId = this.$queue.getData('EditAddress');
  141. if (this.addressId) {
  142. this.getAddressList(this.addressId);
  143. } else {
  144. this.addressMy()
  145. }
  146. },
  147. onLoad(d) {
  148. let peisongSel = this.$queue.getData('peisongSel');
  149. if (peisongSel) {
  150. this.WayList = peisongSel.split(',');
  151. }
  152. if (d.id) {
  153. if (d.maxNumber) {
  154. this.maxNumber = parseFloat(d.maxNumber);
  155. }
  156. this.className = d.className ? d.className : '';
  157. this.id = d.id;
  158. this.groupPinkId = d.groupPinkId;
  159. if (d.userByinvitationId) {
  160. this.userByinvitationId = d.userByinvitationId;
  161. }
  162. if (d.checkString) {
  163. this.money = d.numberMoney;
  164. this.checkString = d.checkString;
  165. this.number = d.number;
  166. this.price = parseFloat(d.money);
  167. this.skuId = d.skuId;
  168. this.attrValuecoverImg = d.attrValuecoverImg;
  169. } else {
  170. this.number = 1;
  171. this.price = parseFloat(d.money);
  172. this.money = d.numberMoney;
  173. }
  174. this.jianMoney = this.price;
  175. this.getCommondityList(d.id);
  176. }
  177. },
  178. methods: {
  179. WaySel(e) {
  180. console.log(e);
  181. // this.sendId = this.WayListTwo[e.detail.value].id;
  182. this.sendName = this.WayList[e.detail.value];
  183. if (this.sendName === '快递') {
  184. this.sendWay = 1;
  185. this.postagePrice = this.postagePrices;
  186. } else if (this.sendName === '自取') {
  187. this.sendWay = 2;
  188. this.postagePrice = 0;
  189. }
  190. },
  191. // 根据地址id查询地址
  192. getAddressList(addressId) {
  193. if (addressId) {
  194. this.$Request.getT('/app/address/selectAddressByAddressId?addressId=' + this.addressId).then(res => {
  195. console.log(res)
  196. if (res.code == 0 && res.data) {
  197. this.checkAddress = true;
  198. this.detail = res.data.city + '' + res.data.district + '' + res.data.detailsAddress;
  199. this.consignee = res.data.name;
  200. this.mobile = res.data.phone;
  201. this.provinces = res.data.province;
  202. // this.name = res.data.name;
  203. // this.mobile = res.data.phone;
  204. // this.cityaddress = res.data.province + res.data.city + res.data.district;
  205. // this.detailaddress = res.data.detailsAddress;
  206. // this.isDefault = res.data.isDefault;
  207. // this.userId = res.data.userId;
  208. // this.latitude = res.data.latitude;
  209. // this.longitude = res.data.longitude;
  210. // this.province = res.data.province
  211. // this.city = res.data.city
  212. // this.district = res.data.district
  213. } else {
  214. this.checkAddress = false;
  215. }
  216. // uni.hideLoading();
  217. });
  218. } else {
  219. uni.navigateTo({
  220. url: '../../../my/address/address?id=' + 1
  221. })
  222. }
  223. },
  224. // 获取默认地址
  225. addressMy() {
  226. this.$Request.getT('/app/address/selectAddressById').then(res => {
  227. console.log(res)
  228. if (res.code == 0 && res.data) {
  229. this.checkAddress = true;
  230. this.detail = res.data.city + '' + res.data.district + '' + res.data.detailsAddress;
  231. this.consignee = res.data.name;
  232. this.mobile = res.data.phone;
  233. this.provinces = res.data.province;
  234. // this.name = res.data.name;
  235. // this.mobile = res.data.phone;
  236. // this.cityaddress = res.data.province + res.data.city + res.data.district;
  237. // this.detailaddress = res.data.detailsAddress;
  238. // this.isDefault = res.data.isDefault;
  239. // this.userId = res.data.userId;
  240. // this.latitude = res.data.latitude;
  241. // this.longitude = res.data.longitude;
  242. // this.province = res.data.province
  243. // this.city = res.data.city
  244. // this.district = res.data.district
  245. // this.addressId = res.data.addressId
  246. } else {
  247. this.checkAddress = false;
  248. }
  249. });
  250. },
  251. numFilter(value) {
  252. // 截取当前数据到小数点后三位
  253. let tempVal = parseFloat(value).toFixed(2)
  254. let realVal = tempVal.substring(0, tempVal.length - 1)
  255. return realVal
  256. },
  257. getCommondityList(id) {
  258. uni.showLoading({
  259. title: '加载中...'
  260. });
  261. this.$Request.getT('/goods/find?id=' + id).then(res => {
  262. if (res.status === 0) {
  263. this.list = res.data;
  264. let relation_id = this.$queue.getData('relation_id');
  265. this.attrValuecoverImg = res.data.coverImg;
  266. if (this.checkString == '') {
  267. this.price = parseFloat(this.list.sku[0].skuPrice);
  268. this.money = parseFloat(this.list.sku[0].skuPrice);
  269. this.maxNumber = this.list.sku[0].stock ? this.list.sku[0].stock : 1;
  270. }
  271. this.isExpress = res.data.isExpress;
  272. this.title = this.list.title;
  273. if (this.list.postagePrice) {
  274. this.postagePrice = 0;
  275. this.postagePrices = parseFloat(this.list.postagePrice);
  276. } else {
  277. this.postagePrice = 0;
  278. this.postagePrices = 0;
  279. }
  280. this.commissionPrice = parseFloat(this.list.commissionPrice);
  281. }
  282. uni.hideLoading();
  283. });
  284. },
  285. // getAddressList() {
  286. // let userId = this.$queue.getData('userId');
  287. // this.$Request.getT('/app/address/findDefaultByUserId?userId=' + userId).then(res => {
  288. // if (res.status === 0) {
  289. // if (res.data) {
  290. // this.checkAddress = true;
  291. // this.detail = res.data.detail;
  292. // this.consignee = res.data.consignee;
  293. // this.mobile = res.data.mobile;
  294. // this.provinces = res.data.provinces;
  295. // } else {
  296. // this.checkAddress = false;
  297. // }
  298. // } else {
  299. // this.checkAddress = false;
  300. // }
  301. // });
  302. // },
  303. goPay() {
  304. if (this.sendWay == 0) {
  305. this.$queue.showToast('请选择配送方式!')
  306. return;
  307. }
  308. if (!this.checkAddress && this.sendName != '自取') {
  309. this.$queue.showToast('请设置收货地址信息');
  310. return;
  311. }
  312. let userId = this.$queue.getData('userId');
  313. if (this.skuId === 0) {
  314. this.skuId = this.list.sku[0].id;
  315. }
  316. var orderType = '1'; //1普通订单 2拼团 3秒杀
  317. var type = '';
  318. var status = '';
  319. var secKillId = '';
  320. var groupId = '';
  321. var goodsId = '';
  322. var isExpress = '';
  323. var commissionPrice = '';
  324. status = '1';
  325. type = this.list.type.id;
  326. goodsId = this.list.id;
  327. isExpress = this.list.isExpress;
  328. commissionPrice = this.commissionPrice;
  329. let data = {
  330. userId: userId,
  331. status: status,
  332. sendWay: this.sendWay,
  333. consignee: this.consignee,
  334. mobile: this.mobile,
  335. provinces: this.provinces,
  336. detail: this.detail,
  337. type: type,
  338. secKillId: secKillId,
  339. groupPinkId: this.groupPinkId,
  340. orderType: orderType,
  341. title: this.list.title,
  342. groupId: groupId,
  343. couponMoney: this.lessMoney, //这个是优惠券金额,替换了descrition的值描述
  344. userCouponsId: this.couponUserId,
  345. goodsId: goodsId,
  346. img: this.attrValuecoverImg,
  347. isExpress: isExpress,
  348. descrition: this.descrition,
  349. skuId: this.skuId,
  350. price: this.money,
  351. number: this.number,
  352. postagePrice: this.postagePrice,
  353. payMoney: this.price + this.postagePrice,
  354. relationId: this.userByinvitationId,
  355. detailJson: this.checkString,
  356. commissionPrice: commissionPrice
  357. }
  358. this.$Request.postJson('/app/orders/save', data).then(res => {
  359. if (res.status === 0) {
  360. uni.redirectTo({
  361. url: '../my/payment?money=' + this.price + '&title=' + this.list.title +
  362. '&img=' + this.list.img + '&id=' +
  363. res.data.id + '&orderType=' + orderType
  364. });
  365. }
  366. });
  367. },
  368. goEditAddress() {
  369. uni.navigateTo({
  370. url: '/my/address/address?id=1'
  371. });
  372. },
  373. jian() {
  374. if (this.number != 1) {
  375. let number = this.number - 1
  376. this.number = number
  377. // this.price = parseFloat(this.price - this.money).toFixed(1);
  378. this.price = parseFloat(this.numFilter(parseFloat(this.price) - parseFloat(this.money)));
  379. }
  380. },
  381. jia() {
  382. let number = this.number + 1
  383. if (this.maxNumber >= number) {
  384. this.number = number
  385. this.price = parseFloat(this.numFilter(parseFloat(this.price) + parseFloat(this.money)));
  386. // this.price = parseFloat(this.price) + parseFloat(this.money);
  387. } else {
  388. this.$queue.showToast('没库存啦,只能买这么多了!');
  389. }
  390. }
  391. }
  392. }
  393. </script>
  394. <style>
  395. page {
  396. background: #F2F2F2;
  397. }
  398. .topic_cont_text {
  399. padding: 30upx;
  400. colof: #999;
  401. background: #E1FFFF;
  402. max-height: 130upx;
  403. overflow: hidden;
  404. word-break: break-all;
  405. /* break-all(允许在单词内换行。) */
  406. text-overflow: ellipsis;
  407. /* 超出部分省略号 */
  408. display: -webkit-box;
  409. /** 对象作为伸缩盒子模型显示 **/
  410. -webkit-box-orient: vertical;
  411. /** 设置或检索伸缩盒对象的子元素的排列方式 **/
  412. -webkit-line-clamp: 2;
  413. /** 显示的行数 **/
  414. }
  415. </style>