demandOrder.vue 14 KB

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