submit2.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <template>
  2. <view class="content">
  3. <view class="box">
  4. <block v-if="address_id == ''">
  5. <view class="hflex acenter jbetween" @click="addAddr">
  6. <view class="title">新增收货地址</view>
  7. <u-icon name="arrow-right" color="#ABABAB" size="11"></u-icon>
  8. </view>
  9. </block>
  10. <block v-else>
  11. <view class="hflex acenter jbetween" @click="addAddr">
  12. <view class="hflex acenter">
  13. <u-icon name="map-fill" color="#506DFF" size="22"></u-icon>
  14. <view class="vflex" style="padding-left: 16rpx;">
  15. <view class="hflex acenter">
  16. <view class="text_style1" style="padding-right: 20rpx;">{{address.name}}</view>
  17. <view class="text_style1">{{address.phone}}</view>
  18. </view>
  19. <view class="text_style2">{{address.address}}</view>
  20. </view>
  21. </view>
  22. <u-icon name="arrow-right" color="#ABABAB" size="11"></u-icon>
  23. </view>
  24. </block>
  25. </view>
  26. <view class="box">
  27. <view class="hflex acenter box_item">
  28. <view>
  29. <image :src="pageData.goods_item[0].goods_cover" mode="aspectFill" class="img"></image>
  30. </view>
  31. <view class="img_right">
  32. <view class="hflex acenter jbetween">
  33. <view class="name text_hide">{{pageData.goods_item[0].goods_name}}</view>
  34. <view class="price">¥{{pageData.goods_item[0].price_selling}}</view>
  35. </view>
  36. <view class="hflex jbetween" style="padding-top: 12rpx;">
  37. <view class="norm text_hide">{{pageData.goods_item[0].goods_spec}}</view>
  38. <view class="vflex">
  39. <view class="num">X{{pageData.goods_item[0].stock_sales}}</view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="hflex acenter jbetween">
  45. <view class="title">订单备注</view>
  46. <u-input v-model="remarks" inputAlign="right" border="none" placeholder="建议留言前先与商家沟通确认"></u-input>
  47. </view>
  48. <!-- <view class="scroll_img" v-else>
  49. <scroll-view scroll-x="true" style="white-space: nowrap;" class="imgs hflex">
  50. <block v-for="(item2,index2) in item.goods_item" :key="index2">
  51. <view class="imgs_item">
  52. <image :src="item2.goods_cover" class="img"></image>
  53. </view>
  54. </block>
  55. </scroll-view>
  56. <view class="img_leng">共{{item.goods_item.length}}件</view>
  57. </view> -->
  58. </view>
  59. <!-- <view class="hflex acenter jend cell" v-if="item.payment_status == 2">
  60. <view class="price">实付款:¥{{item.payment_amount}}</view>
  61. </view> -->
  62. <view class="box">
  63. <view class="hflex acenter jbetween">
  64. <view class="left_text">商品金额</view>
  65. <view class="right_text">¥{{pageData.payment_amount}}</view>
  66. </view>
  67. <!-- <view class="hflex acenter jbetween cell2">
  68. <view class="left_text">运费</view>
  69. <view class="right_text">¥{{freight}}</view>
  70. </view> -->
  71. <view class="hflex acenter jend item_bottom">
  72. <view class="title" style="font-size: 22rpx;">合计:<span class="text_red">¥{{pageData.payment_amount}}</span></view>
  73. </view>
  74. </view>
  75. <view class="box hflex acenter jbetween" style="margin-bottom: 186rpx;">
  76. <view class="hflex acenter">
  77. <image src="/static/images/shop/wx_pay.png" class="pay_icon"></image>
  78. <view class="text_style1">微信支付</view>
  79. </view>
  80. <u-radio-group>
  81. <u-radio activeColor="#506DFF"></u-radio>
  82. </u-radio-group>
  83. </view>
  84. <view class="bottom hflex acenter jend">
  85. <view class="title" style="font-size: 22rpx;" v-if="pageList.length == 0">合计:<span class="text_blue">¥{{pageData.payment_amount}}</span></view>
  86. <view class="title" style="font-size: 22rpx;" v-else>合计:<span class="text_blue">¥{{pageData.payment_amount}}</span></view>
  87. <view class="btn" @click="submit">提交订单</view>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. import $api from '@/static/js/api.js'
  93. var that = ''
  94. export default {
  95. data() {
  96. return {
  97. address: {
  98. },
  99. pageData: {},
  100. pageList: [],
  101. order_id: '',
  102. address_id: '',
  103. pay_no:'',
  104. total: 0,
  105. freight: '0.00',
  106. item_id: '',
  107. cart_ids: '',
  108. buy_num: 1,
  109. remarks: '',
  110. }
  111. },
  112. onLoad(options) {
  113. that = this
  114. console.log(options);
  115. that.pageData = JSON.parse(options.data)
  116. // that.cart_ids = options.cart_ids
  117. that.item_id = options.item_id
  118. // that.address_id = uni.getStorageSync('address_id')
  119. },
  120. onShow() {
  121. that.getAddr()
  122. },
  123. methods: {
  124. getData() {
  125. $api.req({
  126. url: '/data/api.Order/order_info',
  127. method: 'POST',
  128. data: {
  129. order_id: that.order_id,
  130. }
  131. }, function(res) {
  132. if(res.code == 1) {
  133. $api.info(res.info)
  134. that.pageData = res.data
  135. }
  136. })
  137. },
  138. count() {
  139. for(var i=0;i<=that.pageList.length;i++) {
  140. for(var j=0;j<=that.pageList[i].goods_item.length;j++) {
  141. if(that.pageList[i].goods_item[j].num) {
  142. that.total += Number(that.pageList[i].goods_item[j].price_selling) * Number(that.pageList[i].goods_item[j].num)
  143. } else {
  144. that.total += Number(that.pageList[i].goods_item[j].price_selling) * Number(that.pageList[i].goods_item[j].stock_sales)
  145. }
  146. }
  147. }
  148. that.total = that.total.toFixed(2)
  149. },
  150. getAddr() {
  151. that.address_id = uni.getStorageSync('address_id')
  152. if(that.address_id == '') {
  153. return
  154. }
  155. $api.req({
  156. url: '/data/api.User/address_list'
  157. }, function(res) {
  158. if(res.code == 1) {
  159. for(var i=0;i<res.data.data.length;i++) {
  160. if(res.data.data[i].id == that.address_id) {
  161. that.address = res.data.data[i]
  162. }
  163. }
  164. }
  165. })
  166. },
  167. addAddr() {
  168. $api.jump('/page_shop/pages/address/list?select=true')
  169. },
  170. submit() {
  171. if(!that.address_id) {
  172. $api.info("请先选择地址")
  173. return
  174. }
  175. var openid = uni.getStorageSync('openid1')
  176. if(!openid) {
  177. $api.info("登录验证有误,请重新登录")
  178. return
  179. }
  180. if(that.item_id) {
  181. $api.req({
  182. url: '/data/api.Order/order_create',
  183. method: 'POST',
  184. data: {
  185. admin_id: that.pageData.admin_id,
  186. item_id: that.item_id,
  187. num: that.pageData.goods_item[0].stock_sales,
  188. address_id: that.address_id,
  189. order_remark: that.remarks
  190. }
  191. }, function(res) {
  192. if(res.code == 1) {
  193. that.order_id = res.data.order_id
  194. that.pay_no = res.data.pay_no
  195. $api.req({
  196. url: '/data/api.auth.Center/channel',
  197. method: 'POST',
  198. data: {
  199. type: 2,
  200. from: 1
  201. }
  202. }, function(res) {
  203. if(res.code == 1) {
  204. var pay_code = res.data[0].code
  205. $api.req({
  206. url: '/data/api.Order/order_pay',
  207. method: 'POST',
  208. data: {
  209. pay_code: pay_code,
  210. pay_no: that.pay_no,
  211. type: 'wechat'
  212. }
  213. }, function(res) {
  214. if(res.code == 1) {
  215. wx.requestPayment({
  216. timeStamp: res.data.pay.timeStamp,
  217. nonceStr: res.data.pay.nonceStr,
  218. package: res.data.pay.package,
  219. signType: 'MD5',
  220. paySign: res.data.pay.paySign,
  221. success (res) {
  222. $api.jump('/page_shop/pages/order/paySuccess?id=' +that.order_id ,2)
  223. },
  224. fail (res) { }
  225. })
  226. }
  227. })
  228. }
  229. })
  230. }
  231. })
  232. } else {
  233. $api.req({
  234. url: '/data/api.Order/crat_create',
  235. method: 'POST',
  236. data: {
  237. cart_ids: that.cart_ids,
  238. address_id: that.address_id,
  239. order_remark: that.remarks
  240. }
  241. }, function(res) {
  242. if(res.code == 1) {
  243. that.pay_no = res.data
  244. $api.req({
  245. url: '/data/api.auth.Center/channel',
  246. method: 'POST',
  247. data: {
  248. type: 2,
  249. from: 1
  250. }
  251. }, function(res) {
  252. if(res.code == 1) {
  253. var pay_code = res.data[0].code
  254. $api.req({
  255. url: '/data/api.Order/order_pay',
  256. method: 'POST',
  257. data: {
  258. pay_code: pay_code,
  259. pay_no: that.pay_no,
  260. type: 'wechat'
  261. }
  262. }, function(res) {
  263. if(res.code == 1) {
  264. wx.requestPayment({
  265. timeStamp: res.data.pay.timeStamp,
  266. nonceStr: res.data.pay.nonceStr,
  267. package: res.data.pay.package,
  268. signType: 'MD5',
  269. paySign: res.data.pay.paySign,
  270. success (res) {
  271. $api.jump('/page_shop/pages/order/paySuccess?id=' +that.order_id ,2)
  272. },
  273. fail (res) { }
  274. })
  275. }
  276. })
  277. }
  278. })
  279. }
  280. })
  281. }
  282. }
  283. },
  284. }
  285. </script>
  286. <style lang="scss" scoped>
  287. .content::v-deep {
  288. background-color: #F4F4F4;
  289. .box {
  290. background: #FFFFFF;
  291. border-radius: 10px;
  292. margin: 20rpx auto 0;
  293. width: 690rpx;
  294. box-sizing: border-box;
  295. padding: 34rpx 20rpx;
  296. .title {
  297. font-size: 32rpx;
  298. font-weight: 500;
  299. color: #222222;
  300. line-height: 44rpx;
  301. }
  302. .text_style1 {
  303. font-size: 28rpx;
  304. font-weight: 500;
  305. color: #222222;
  306. line-height: 40rpx;
  307. }
  308. .text_style2 {
  309. font-size: 26rpx;
  310. font-weight: 400;
  311. color: #888888;
  312. line-height: 36rpx;
  313. }
  314. .cell {
  315. padding: 20rpx 0 32rpx;
  316. }
  317. .cell2 {
  318. padding: 32rpx 0 20rpx;
  319. }
  320. .img {
  321. width: 160rpx;
  322. height: 160rpx;
  323. border-radius: 24rpx;
  324. }
  325. .img_right {
  326. width:calc(100% - 160rpx);
  327. padding-left: 20rpx;
  328. .item_name {
  329. font-size: 30rpx;
  330. font-weight: 400;
  331. color: #222222;
  332. line-height: 42rpx;
  333. }
  334. .norm {
  335. max-width: 288rpx;
  336. width: max-content;
  337. background: #F5F5F5;
  338. border-radius: 12rpx;
  339. box-sizing: border-box;
  340. padding: 12rpx 12rpx 5rpx;
  341. font-size: 20rpx;
  342. font-weight: 400;
  343. color: #888888;
  344. line-height: 28rpx;
  345. text-overflow: ellipsis;
  346. overflow: hidden;
  347. display: -webkit-box;
  348. -webkit-box-orient: vertical;
  349. box-orient: vertical;
  350. line-clamp: 2;
  351. -webkit-line-clamp: 2;
  352. }
  353. }
  354. .left_text {
  355. font-size: 24rpx;
  356. font-weight: 500;
  357. color: #888888;
  358. line-height: 28rpx;
  359. }
  360. .right_text {
  361. font-size: 24rpx;
  362. font-weight: bold;
  363. color: #222222;
  364. line-height: 28rpx;
  365. }
  366. .item_bottom {
  367. padding-top: 22rpx;
  368. border-top: 1rpx solid #F4F4F4;
  369. }
  370. .text_red {
  371. font-weight: bold;
  372. color: #EE5850;
  373. }
  374. .pay_icon {
  375. width: 48rpx;
  376. height: 48rpx;
  377. margin-right: 20rpx;
  378. }
  379. .check_icon {
  380. width: 32rpx;
  381. height: 32rpx;
  382. }
  383. .box_item {
  384. background: #FFFFFF;
  385. border-radius: 20rpx;
  386. width: 100%;
  387. margin-top: 20rpx;
  388. box-sizing: border-box;
  389. padding: 0 20rpx;
  390. .cell {
  391. padding: 20rpx 0;
  392. }
  393. .title {
  394. font-size: 30rpx;
  395. font-weight: 500;
  396. color: #333333;
  397. line-height: 42rpx;
  398. }
  399. .text-blue {
  400. font-size: 26rpx;
  401. font-weight: 400;
  402. color: #506DFF;
  403. line-height: 36rpx;
  404. }
  405. .img {
  406. width: 160rpx;
  407. height: 160rpx;
  408. border-radius: 16rpx;
  409. }
  410. .img_right {
  411. margin-left: 16rpx;
  412. width: calc(100% - 176rpx);
  413. .name {
  414. width: 392rpx;
  415. font-size: 28rpx;
  416. font-weight: 500;
  417. color: #222222;
  418. line-height: 40rpx;
  419. }
  420. .norm {
  421. width: max-content;
  422. // height: max-content;
  423. max-width: 400rpx;
  424. // height: 84rpx;
  425. background: #F5F5F5;
  426. border-radius: 4rpx;
  427. font-size: 22rpx;
  428. font-weight: 400;
  429. color: #888888;
  430. line-height: 32rpx;
  431. box-sizing: border-box;
  432. padding: 12rpx;
  433. }
  434. .num {
  435. font-size: 24rpx;
  436. font-weight: 500;
  437. color: #888888;
  438. line-height: 28rpx;
  439. }
  440. .text_red {
  441. font-size: 26rpx;
  442. font-weight: 400;
  443. color: #FF2626;
  444. line-height: 36rpx;
  445. padding-top: 18rpx;
  446. }
  447. }
  448. .scroll_img {
  449. position: relative;
  450. .imgs {
  451. width: 100%;
  452. height: 170rpx;
  453. overflow: hidden;
  454. white-space: nowrap;
  455. .imgs_item {
  456. width: 160rpx;
  457. height: 160rpx;
  458. border-radius: 16rpx;
  459. margin-right: 20rpx;
  460. display: inline-block;
  461. }
  462. }
  463. .img_leng {
  464. position: absolute;
  465. right: 0;
  466. top: 0;
  467. width: 130rpx;
  468. height: 160rpx;
  469. border-radius: 12rpx;
  470. font-size: 24rpx;
  471. font-weight: 500;
  472. color: #222222;
  473. line-height: 160rpx;
  474. text-align: center;
  475. background: linear-gradient(270deg, #FFFFFF 0%, rgba(255,255,255,0.78) 100%);
  476. }
  477. }
  478. .price {
  479. font-size: 30rpx;
  480. font-weight: 400;
  481. color: #222222;
  482. line-height: 24rpx;
  483. }
  484. .btn1 {
  485. width: 180rpx;
  486. height: 68rpx;
  487. border-radius: 36rpx;
  488. border: 1px solid #D0D0D0;
  489. text-align: center;
  490. font-size: 28rpx;
  491. font-weight: 400;
  492. color: #222222;
  493. line-height: 68rpx;
  494. }
  495. .btn2 {
  496. border: 1px solid #506DFF;
  497. color: #506DFF;
  498. margin-left: 32rpx;
  499. }
  500. }
  501. }
  502. .u-radio-group {
  503. flex: 0 !important;
  504. }
  505. .bottom {
  506. width: 100%;
  507. height: 166rpx;
  508. background: #FFFFFF;
  509. z-index: 9;
  510. position: fixed;
  511. bottom: 0;
  512. box-sizing: border-box;
  513. padding: 8rpx 50rpx 74rpx;
  514. .title {
  515. font-size: 24rpx;
  516. font-weight: 400;
  517. color: #222222;
  518. line-height: 34rpx;
  519. }
  520. .text_blue {
  521. font-size: 44rpx;
  522. color: #5270FF;
  523. }
  524. .btn{
  525. margin-left: 16rpx;
  526. width: 260rpx;
  527. height: 84rpx;
  528. background: #506DFF;
  529. border-radius: 42rpx;
  530. text-align: center;
  531. font-size: 36rpx;
  532. font-weight: 500;
  533. color: #FFFFFF;
  534. line-height: 84rpx;
  535. }
  536. }
  537. }
  538. </style>