errandsOrder.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. <template>
  2. <view class="container">
  3. <form>
  4. <view class="tui-box">
  5. <tui-list-cell :arrow="true" unlined :radius="true" @click="takechooseAddr">
  6. <view class="tui-address">
  7. <label class="serviceaddr">取件地址</label>
  8. <view v-if="takeAddressData.address">
  9. <view class="tui-userinfo">
  10. <text class="tui-name">{{takeAddressData.name}}</text>{{takeAddressData.telephone}}
  11. </view>
  12. <view class="tui-addr">
  13. <text>{{takeAddressData.address_default}}{{takeAddressData.address}}</text>
  14. </view>
  15. </view>
  16. <view class="tui-none-addr" v-else>
  17. <image src="/static/images/location_fill.png" class="tui-addr-img" mode="widthFix"></image>
  18. <text>请选择地址</text>
  19. </view>
  20. </view>
  21. </tui-list-cell>
  22. <tui-list-cell :arrow="true" unlined :radius="true" @click="curchooseAddr">
  23. <view class="tui-address">
  24. <label class="serviceaddr">收件地址</label>
  25. <view v-if="curAddressData.address">
  26. <view class="tui-userinfo">
  27. <text class="tui-name">{{curAddressData.name}}</text>{{curAddressData.telephone}}
  28. </view>
  29. <view class="tui-addr">
  30. <text>{{curAddressData.address_default}}{{curAddressData.address}}</text>
  31. </view>
  32. </view>
  33. <view class="tui-none-addr" v-else>
  34. <image src="/static/images/location_fill.png" class="tui-addr-img" mode="widthFix"></image>
  35. <text>请选择地址</text>
  36. </view>
  37. </view>
  38. </tui-list-cell>
  39. <tui-list-cell :hover="false" :lineLeft="false" padding="0">
  40. <view class="tui-remark-box tui-padding tui-flex">
  41. <view>路程</view>
  42. {{distance}}公里
  43. </view>
  44. </tui-list-cell>
  45. <tui-list-cell :hover="false" :lineLeft="false" padding="0">
  46. <view class="tui-remark-box tui-padding tui-flex">
  47. <view>跑腿费</view>
  48. {{amountTotle}}元
  49. </view>
  50. </tui-list-cell>
  51. <tui-list-cell :hover="false" :lineLeft="false" padding="0">
  52. <view class="tui-remark-box tui-padding tui-flex">
  53. <view>备注</view>
  54. <input type="text" @input="remarkInput" name="remark" class="tui-remark" placeholder="请输入您的要求"
  55. placeholder-class="tui-phcolor"></input>
  56. </view>
  57. </tui-list-cell>
  58. </view>
  59. <view class="tui-safe-area"></view>
  60. <view class="tui-tabbar">
  61. <view class="tui-flex-end tui-color-red tui-pr-20">
  62. <view class="tui-black">应付金额: </view>
  63. <view class="tui-size-26">¥</view>
  64. <view class="tui-price-large">{{amountTotle}}</view>
  65. <!--<view class="tui-size-26"></view>-->
  66. </view>
  67. <view class="tui-pr25">
  68. <button class="paybutt" @click="btnPay" :style="'background:'+ pagestyleconfig.appstylecolor">确认下单</button>
  69. </view>
  70. </view>
  71. <t-pay-way :show="show" :stylecolor="pagestyleconfig.appstylecolor" :amuont="amountTotle" @goPay="goPay" :paymethod="paymethod" @close="popupClose">
  72. </t-pay-way>
  73. </form>
  74. </view>
  75. </template>
  76. <script>
  77. import tPayWay from "@/components/views/t-pay-way/t-pay-way"
  78. import pay from '@/common/pay.js'
  79. export default {
  80. components: {
  81. tPayWay
  82. },
  83. data() {
  84. return {
  85. show: false,
  86. pagestyleconfig: [],
  87. distance: 0,
  88. amountTotle: 0,
  89. islogin: 1, //是否要需要登录,需要在onLoad加截 app.page.onLoad(this,e);
  90. servicetime: '',
  91. address_id: '',
  92. take_address_id: '',
  93. curAddressData: [],
  94. takeAddressData: [],
  95. total: 0,
  96. remark: "",
  97. selIndex: 0,
  98. payment: '0', //是否支持货到付款
  99. chargeset: '0', //是否开启服务费
  100. paymentType: "",
  101. deliverymode: '1',
  102. ptype: 2,
  103. service: 0,
  104. paymethod: {},
  105. }
  106. },
  107. onLoad: function(e) {
  108. let _this = this
  109. uni.setStorageSync('gotopage', '/pagesA/submitOrder/errandsOrder');
  110. this.sam.checktelephone().then(res => {});
  111. _this.$request.post('config', {
  112. mo: 'pagestyle'
  113. }).then(res => {
  114. if (res.errno == 0) {
  115. _this.pagestyleconfig = res.data
  116. }
  117. });
  118. _this.$request.get('Paymethod.list').then(res => {
  119. if (res.errno == 0) {
  120. _this.paymethod = res.data;
  121. _this.paymentType = res.data[0].default;
  122. //console.log(_this.paymentType);
  123. }
  124. })
  125. },
  126. onShow: function() {
  127. let _this = this
  128. _this.address_id = uni.getStorageSync('address_id');
  129. _this.take_address_id = uni.getStorageSync('take_address_id');
  130. if (_this.address_id) {
  131. _this.$request.get('address.getinfobyid', {
  132. samkey: (new Date()).valueOf(),
  133. id: _this.address_id
  134. }).then(res => {
  135. if (res.errno === 0) {
  136. _this.curAddressData = res.data;
  137. }
  138. })
  139. }
  140. if (_this.take_address_id) {
  141. _this.$request.get('address.getinfobyid', {
  142. samkey: (new Date()).valueOf(),
  143. id: _this.take_address_id
  144. }).then(res => {
  145. if (res.errno === 0) {
  146. _this.takeAddressData = res.data;
  147. }
  148. })
  149. }
  150. if (_this.address_id && _this.take_address_id) {
  151. _this.$request.post('order.taketotal', {
  152. samkey: (new Date()).valueOf(),
  153. address_id: _this.address_id,
  154. take_address_id: _this.take_address_id
  155. }).then(res => {
  156. if (res.errno === 0) {
  157. _this.distance = res.data.distance;
  158. _this.amountTotle = res.data.amountTotle;
  159. }
  160. })
  161. }
  162. },
  163. methods: {
  164. takechooseAddr() {
  165. uni.navigateTo({
  166. url: "/pagesA/my/address/address?atype=take"
  167. })
  168. },
  169. curchooseAddr() {
  170. uni.navigateTo({
  171. url: "/pagesA/my/address/address"
  172. })
  173. },
  174. btnPay() {
  175. var _this = this;
  176. if (!_this.takeAddressData.id) {
  177. uni.hideLoading();
  178. uni.showModal({
  179. title: '错误',
  180. content: '请添加取件地址!',
  181. showCancel: false
  182. })
  183. return;
  184. }
  185. if (!_this.curAddressData.id) {
  186. uni.hideLoading();
  187. uni.showModal({
  188. title: '错误',
  189. content: '请添加收件地址!',
  190. showCancel: false
  191. })
  192. return;
  193. }
  194. this.show = true
  195. },
  196. popupClose() {
  197. this.show = false
  198. },
  199. goPay(e) {
  200. if (e.paymentType) {
  201. this.paymentType = e.paymentType;
  202. }
  203. this.createOrder();
  204. },
  205. createOrder: function() {
  206. var _this = this;
  207. if (_this.remark == undefined) {
  208. _this.remark = '';
  209. }
  210. let postData = {
  211. otype: 2,
  212. remark: _this.remark,
  213. distance: _this.distance,
  214. amountTotle: _this.amountTotle,
  215. paymentType: _this.paymentType
  216. };
  217. if (_this.paymentType == 0) {
  218. uni.hideLoading();
  219. uni.showModal({
  220. title: '错误',
  221. content: '请选择支付方式!',
  222. showCancel: false
  223. })
  224. return;
  225. }
  226. postData.address_id = _this.curAddressData.id;
  227. postData.take_address_id = _this.takeAddressData.id;
  228. _this.ptype = 2;
  229. _this.$request.post('order.errandscreate', postData).then(res => {
  230. if (res.errno != 0) {
  231. uni.showModal({
  232. title: '错误',
  233. content: res.msg,
  234. showCancel: false
  235. })
  236. return;
  237. }
  238. const redirectUrl = "/pagesA/submitOrder/success?ptype=" + _this.ptype;
  239. if (res.data.payment_code == 'wx_pay') {
  240. pay.wxpay('order', res.data.pay_total, res.data.id, redirectUrl);
  241. } else if (res.data.payment_code == 'balance_pay') {
  242. _this.$request.post('order.pay', {
  243. orderid: res.data.id
  244. }).then(res => {
  245. if (res.errno == 0) {
  246. wx.showModal({
  247. title: '成功',
  248. content: '使用余额支付成功',
  249. showCancel: false,
  250. success: function(res) {
  251. wx.redirectTo({
  252. url: redirectUrl
  253. });
  254. }
  255. })
  256. } else {
  257. wx.showModal({
  258. title: '失败',
  259. content: res.msg,
  260. showCancel: false
  261. })
  262. }
  263. })
  264. } else if (res.data.payment_code == 'offline_pay') {
  265. _this.sam.navigateTo('/pagesA/submitOrder/offlinepayment?id=' + res.data.id);
  266. } else if (res.data.payment_code == 'delivery_pay') {
  267. _this.sam.navigateTo(redirectUrl);
  268. } else {
  269. _this.sam.navigateTo(redirectUrl);
  270. }
  271. })
  272. },
  273. remarkInput: function(e) {
  274. this.remark = e.target.value;
  275. },
  276. },
  277. /**
  278. * 页面相关事件处理函数--监听用户下拉动作
  279. */
  280. onPullDownRefresh: function() {
  281. setTimeout(() => {
  282. uni.stopPullDownRefresh()
  283. }, 200);
  284. },
  285. }
  286. </script>
  287. <style>
  288. .container {
  289. padding-bottom: 98rpx;
  290. }
  291. .tui-item-box {
  292. width: 100%;
  293. display: flex;
  294. align-items: center;
  295. }
  296. .tui-list-cell_name {
  297. padding-left: 5rpx;
  298. display: flex;
  299. align-items: center;
  300. justify-content: center;
  301. }
  302. .tui-right {
  303. margin-left: auto;
  304. margin-right: 34rpx;
  305. font-size: 26rpx;
  306. color: #999;
  307. }
  308. .tui-box {
  309. padding: 20rpx 0 118rpx;
  310. box-sizing: border-box;
  311. }
  312. .tui-address {
  313. min-height: 80rpx;
  314. padding: 10rpx 0;
  315. box-sizing: border-box;
  316. position: relative;
  317. }
  318. .serviceaddr {
  319. color: #999999;
  320. }
  321. .tui-userinfo {
  322. font-size: 30rpx;
  323. font-weight: 500;
  324. line-height: 30rpx;
  325. padding-top: 10rpx;
  326. padding-bottom: 12rpx;
  327. }
  328. .tui-name {
  329. padding-right: 40rpx;
  330. }
  331. .tui-addr {
  332. font-size: 24rpx;
  333. word-break: break-all;
  334. padding-right: 25rpx;
  335. }
  336. .tui-addr-tag {
  337. padding: 5rpx 8rpx;
  338. flex-shrink: 0;
  339. background: #EB0909;
  340. color: #fff;
  341. display: inline-flex;
  342. align-items: center;
  343. justify-content: center;
  344. font-size: 25rpx;
  345. line-height: 25rpx;
  346. transform: scale(0.8);
  347. transform-origin: 0 center;
  348. border-radius: 6rpx;
  349. }
  350. .tui-top {
  351. margin-top: 20rpx;
  352. overflow: hidden;
  353. }
  354. .tui-goods-title {
  355. font-size: 28rpx;
  356. display: flex;
  357. align-items: center;
  358. }
  359. .tui-padding {
  360. box-sizing: border-box;
  361. }
  362. .tui-goods-item {
  363. width: 100%;
  364. padding: 20rpx 30rpx;
  365. box-sizing: border-box;
  366. display: flex;
  367. justify-content: space-between;
  368. }
  369. .tui-goods-img {
  370. width: 180rpx;
  371. height: 180rpx;
  372. display: block;
  373. flex-shrink: 0;
  374. }
  375. .tui-goods-center {
  376. flex: 1;
  377. padding: 20rpx 8rpx;
  378. box-sizing: border-box;
  379. }
  380. .tui-goods-name {
  381. max-width: 310rpx;
  382. word-break: break-all;
  383. overflow: hidden;
  384. text-overflow: ellipsis;
  385. display: -webkit-box;
  386. -webkit-box-orient: vertical;
  387. -webkit-line-clamp: 2;
  388. font-size: 26rpx;
  389. line-height: 32rpx;
  390. }
  391. .tui-goods-attr {
  392. font-size: 22rpx;
  393. color: #888888;
  394. line-height: 32rpx;
  395. padding-top: 20rpx;
  396. word-break: break-all;
  397. overflow: hidden;
  398. text-overflow: ellipsis;
  399. display: -webkit-box;
  400. -webkit-box-orient: vertical;
  401. -webkit-line-clamp: 2;
  402. }
  403. .tui-price-right {
  404. text-align: right;
  405. font-size: 24rpx;
  406. color: #888888;
  407. line-height: 30rpx;
  408. padding-top: 20rpx;
  409. }
  410. .tui-flex {
  411. width: 100%;
  412. display: flex;
  413. align-items: center;
  414. justify-content: space-between;
  415. font-size: 26rpx;
  416. }
  417. .tui-total-flex {
  418. justify-content: flex-end;
  419. }
  420. .tui-color-red {
  421. color: #E41F19;
  422. padding-right: 30rpx;
  423. }
  424. .tui-balance {
  425. font-size: 28rpx;
  426. font-weight: 500;
  427. }
  428. .tui-black {
  429. color: #222;
  430. line-height: 30rpx;
  431. }
  432. .tui-gray {
  433. color: #888888;
  434. font-weight: 400;
  435. }
  436. .tui-light-dark {
  437. color: #666;
  438. }
  439. .tui-goods-price {
  440. display: flex;
  441. align-items: center;
  442. padding-top: 20rpx;
  443. }
  444. .tui-size-26 {
  445. font-size: 26rpx;
  446. line-height: 26rpx;
  447. }
  448. .tui-price-large {
  449. font-size: 34rpx;
  450. line-height: 32rpx;
  451. font-weight: 600;
  452. }
  453. .tui-flex-end {
  454. display: flex;
  455. align-items: flex-end;
  456. padding-right: 0;
  457. }
  458. .tui-phcolor {
  459. color: #B3B3B3;
  460. font-size: 26rpx;
  461. }
  462. /* #ifndef H5 */
  463. .tui-remark-box {
  464. padding: 22rpx 30rpx;
  465. }
  466. /* #endif */
  467. /* #ifdef H5 */
  468. .tui-remark-box {
  469. padding: 26rpx 30rpx;
  470. }
  471. /* #endif */
  472. .tui-remark {
  473. flex: 1;
  474. font-size: 26rpx;
  475. padding-left: 64rpx;
  476. }
  477. .tui-scale-small {
  478. transform: scale(0.8);
  479. transform-origin: 100% center;
  480. }
  481. .tui-scale-small .wx-switch-input {
  482. margin: 0 !important;
  483. }
  484. /* #ifdef H5 */
  485. >>>uni-switch .uni-switch-input {
  486. margin-right: 0 !important;
  487. }
  488. /* #endif */
  489. .tui-tabbar {
  490. width: 100%;
  491. height: 98rpx;
  492. background: #fff;
  493. position: fixed;
  494. left: 0;
  495. bottom: 0;
  496. display: flex;
  497. align-items: center;
  498. justify-content: flex-end;
  499. font-size: 26rpx;
  500. box-shadow: 0 0 1px rgba(0, 0, 0, .3);
  501. padding-bottom: env(safe-area-inset-bottom);
  502. z-index: 996;
  503. }
  504. .tui-pr-30 {
  505. padding-right: 30rpx;
  506. }
  507. .tui-pr-20 {
  508. padding-right: 20rpx;
  509. }
  510. .tui-none-addr {
  511. height: 80rpx;
  512. padding-left: 5rpx;
  513. display: flex;
  514. align-items: center;
  515. }
  516. .tui-addr-img {
  517. width: 36rpx;
  518. height: 46rpx;
  519. display: block;
  520. margin-right: 15rpx;
  521. }
  522. .tui-pr25 {
  523. padding-right: 25rpx;
  524. }
  525. .paybutt {
  526. width: 380rpx;
  527. height: 70rpx;
  528. line-height: 70rpx;
  529. font-size: 28rpx;
  530. border-radius: 50rpx;
  531. color: #ffffff;
  532. align-items: center;
  533. }
  534. .tui-safe-area {
  535. height: 1rpx;
  536. padding-bottom: env(safe-area-inset-bottom);
  537. }
  538. .tui-pay-item__title {
  539. width: 100%;
  540. height: 90rpx;
  541. display: flex;
  542. align-items: center;
  543. justify-content: space-between;
  544. padding: 0 20rpx;
  545. box-sizing: border-box;
  546. font-size: 28rpx;
  547. }
  548. .tui-pay-amuont {
  549. color: #eb0909;
  550. font-weight: 500;
  551. font-size: 34rpx;
  552. }
  553. .tui-pay-item {
  554. width: 100%;
  555. height: 80rpx;
  556. display: flex;
  557. align-items: center;
  558. padding: 0 20rpx;
  559. box-sizing: border-box;
  560. font-size: 28rpx;
  561. }
  562. .tui-pay-logo {
  563. width: 48rpx;
  564. height: 48rpx;
  565. margin-right: 15rpx;
  566. }
  567. .tui-radio {
  568. margin-left: auto;
  569. transform: scale(0.8);
  570. transform-origin: 100% center;
  571. }
  572. .tui-btn-pay {
  573. width: 100%;
  574. padding: 68rpx 60rpx 50rpx;
  575. box-sizing: border-box;
  576. }
  577. .tui-recharge {
  578. color: #fc872d;
  579. margin-left: auto;
  580. padding: 12rpx 0;
  581. }
  582. .acea-row {
  583. font-size: 28rpx;
  584. padding-top: 30rpx;
  585. padding-left: 20rpx;
  586. height: 60rpx;
  587. background-color: #fff;
  588. }
  589. .acea-row label {
  590. padding: 10rpx;
  591. }
  592. </style>