Cityservice.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275
  1. <template>
  2. <view class="help_send" style="padding-bottom: 10upx;">
  3. <view class="part_two">
  4. <view class="service_box" @click="bindadd(4)">
  5. <view class="flex-sub margin-left-sm">
  6. <view class="service_name" style="font-weight: bold;">
  7. 服务地址
  8. </view>
  9. </view>
  10. <view class="service_address" v-if="JSON.stringify(citydata) != '{}'">
  11. <view class="service_name">
  12. {{citydata.province}}{{citydata.city}}{{citydata.district}}{{citydata.addressDetail}}
  13. </view>
  14. <view class="service_dd">
  15. {{citydata.userName}}
  16. <text>{{citydata.userPhone}}</text>
  17. </view>
  18. </view>
  19. <view class="text-lg" v-else>请选择地址</view>
  20. <view class="service_icon">
  21. <u-icon name="arrow-right"></u-icon>
  22. </view>
  23. </view>
  24. <u-line color="#E6E6E6" />
  25. <u-form :model="forms" ref="uForm" label-position="left" :label-style="labelstyle">
  26. <u-form-item label="服务时间" right-icon="arrow-right">
  27. <u-input @click="onshowdata" :clearable="clearable" :disabled="true" v-model="forms.data"
  28. input-align="right" placeholder="请确定服务时间" />
  29. </u-form-item>
  30. </u-form>
  31. </view>
  32. <view class="part_four" @click="bindtype()" v-if='title'>
  33. <view class="service_type">服务类型</view>
  34. <view class="service_type text-right">{{citytype}}</view>
  35. <view class="service_you">
  36. <u-icon name="arrow-right"></u-icon>
  37. </view>
  38. </view>
  39. <view class="part_one">
  40. <view class="pay_tit">
  41. <view class="pay_name">服务内容</view>
  42. <view class="pay_set">
  43. <u-input v-model="values" type="textarea" :maxlength="500" :placeholder='placeholder' />
  44. </view>
  45. </view>
  46. </view>
  47. <view class="part_three">
  48. <u-form :model="forms" ref="uForm" label-position="left" :label-style="labelstyle">
  49. <!-- <u-form-item label="自备配件" right-icon="arrow-right">
  50. <u-input @click="onshowm" :clearable="clearable" :disabled="true" v-model="forms.peijian"
  51. input-align="right" />
  52. </u-form-item> -->
  53. <!-- <u-form-item label="保修期" right-icon="arrow-right">
  54. <u-input @click="onshowvalua" v-model="forms.baoxiu" :disabled="true" :clearable="clearable"
  55. input-align="right" />
  56. </u-form-item> -->
  57. <u-form-item label="红包" right-icon="arrow-right">
  58. <u-input @click="onshowmoney" v-model="forms.hongbao" :disabled="true" :clearable="clearable"
  59. input-align="right" placeholder="请选择红包" />
  60. </u-form-item>
  61. <u-form-item label="小费" right-icon="arrow-right">
  62. <u-input v-model="forms.tip" type="number" :clearable="clearable" input-align="right"
  63. @input="onKeyInput()" placeholder="接单更快 购买更加及时" />
  64. </u-form-item>
  65. </u-form>
  66. </view>
  67. <view class="content_sure">
  68. <u-checkbox-group>
  69. <u-checkbox v-model="check" shape="circle" active-color="#FF7F00">同意并接受</u-checkbox>
  70. </u-checkbox-group>
  71. <view style="font-size: 25rpx;margin-left: -10rpx;" @click="binduserxieyi()">
  72. 《跑腿代购服务用户协议》
  73. </view>
  74. </view>
  75. <view class="tabbar">
  76. <view class="tabbar_price">支付:
  77. <text v-if="totalprice == ''">¥{{price || 0}}</text>
  78. <text v-else>¥{{totalprice}}</text>
  79. </view>
  80. <view class="tabbar_btn">
  81. <view class="but" @click="bindpay()">提交并支付</view>
  82. </view>
  83. </view>
  84. <!-- 服务类型弹框 -->
  85. <u-select v-model="typeshow" mode="single-column" value-name='id' label-name='serviceName' :list="list" @confirm="typeconfirm"></u-select>
  86. <!-- 取件时间弹框 :range="multiSelector"-->
  87. <u-picker mode="time" v-model="showdata" :default-selector='[0, 0]' cancel-tex="确认" :params="params"
  88. @confirm="confirm"></u-picker>
  89. <!-- 上门配件弹框 -->
  90. <u-select v-model="menshow" mode="single-column" :list="mlist" @confirm="confirms"></u-select>
  91. <!-- 红包弹框 -->
  92. <u-popup v-model="showmoney" mode="bottom" :closeable="true" close-icon="close-circle"
  93. close-icon-pos="top-right" close-icon-color="#8f9298" close-icon-size="50">
  94. <view class="popup_money">
  95. <view class="data_title">红包</view>
  96. <view class="data_select">
  97. <view class="money_box" v-for="(item,index) in hongbao" :key="index"
  98. v-if="Number(item.redPacketType)==0||Number(item.redPacketType)==indentType">
  99. <view class="box_tit">
  100. <view class="money_name">{{item.redPacketTitle}}</view>
  101. <view class="money_price">¥{{item.redPacketAmount}}</view>
  102. </view>
  103. <view class="money_data">有效期至{{item.expirationTime}}</view>
  104. <view class="money_line">
  105. <u-line direction="row" color="#E6E6E6" border-style="dashed" />
  106. </view>
  107. <view class="box_bottom">
  108. <view class="money_use">满{{item.minimumAmount}}元可使用</view>
  109. <view class="money_btn">
  110. <view class="lj_use" @click="bindhongindex(item.redPacketId,item.redPacketAmount)">
  111. 立即使用
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 暂无红包 -->
  118. <view class="image_box" v-if="hongbao.length==0">
  119. <image src="../../static/images/empty.png" style="width:100%;height: 350rpx;"></image>
  120. <view style="width: 100%;text-align: center;color: #ccc;">暂无红包</view>
  121. </view>
  122. </view>
  123. </u-popup>
  124. <u-popup v-model="showpay" mode="bottom" close-icon="close-circle" close-icon-pos="top-right"
  125. close-icon-color="#8f9298" close-icon-size="50">
  126. <view class="popup_pay">
  127. <view class="bg margin-top padding-lr radius">
  128. <view style="padding: 0 20upx;margin-top: 36rpx;">
  129. <view
  130. style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;justify-content: center;"
  131. v-for="(item,index) in openLists" :key='index'>
  132. <image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;">
  133. </image>
  134. <view style="font-size: 30upx;margin-left: 20upx;width: 70%;">
  135. {{item.text}}
  136. </view>
  137. <radio-group name="openWay" style="margin-left: 20upx;" @tap='selectWay(item)'>
  138. <label class="tui-radio">
  139. <radio color="#FF7F00" :checked="openWay === item.id ? true : false" />
  140. </label>
  141. </radio-group>
  142. </view>
  143. </view>
  144. </view>
  145. <view class="pay_btns" @click="pay()">确认支付</view>
  146. </view>
  147. </u-popup>
  148. </view>
  149. </template>
  150. <script>
  151. export default {
  152. data() {
  153. return {
  154. title: true,
  155. openWay: 0,
  156. typeshow: false,
  157. values: '',
  158. placeholder: '请填写服务内容',
  159. list: [
  160. {
  161. value: '1',
  162. label: '全能帮手'
  163. }, {
  164. value: '2',
  165. label: '搬运货取'
  166. }, {
  167. value: '3',
  168. label: '小时工'
  169. }, {
  170. value: '4',
  171. label: '照顾宠物'
  172. }, {
  173. value: '5',
  174. label: '传单派发'
  175. }, {
  176. value: '6',
  177. label: '活动招募'
  178. }, {
  179. value: '7',
  180. label: '异地代办'
  181. }, {
  182. value: '8',
  183. label: '上门做饭'
  184. },
  185. ],
  186. menshow: false,
  187. mlist: [{
  188. value: '1',
  189. label: '不需要配件'
  190. }, {
  191. value: '2',
  192. label: '需要配件'
  193. }],
  194. // checked: false,
  195. check: false,
  196. mobile: '',
  197. code: '',
  198. forms: {
  199. data: '立即上门',
  200. baoxiu: '7天',
  201. hongbao: '',
  202. tip: '',
  203. peijian: ''
  204. },
  205. clearable: false,
  206. showdata: false,
  207. showmoney: false,
  208. showpay: false,
  209. value: '',
  210. type: 'text',
  211. border: true,
  212. params: {
  213. // year: true,
  214. // month: true,
  215. day: true,
  216. hour: true,
  217. minute: true,
  218. timestamp: true
  219. },
  220. price: 0,
  221. indentType: '4',
  222. cityPrice: {},
  223. hongbao: [],
  224. citydata: {},
  225. citytype: '',
  226. redPacketId: '',
  227. year: '',
  228. labelstyle: {
  229. whiteSpace: 'nowrap',
  230. fontWeight: 'bold',
  231. textIndent: '20rpx'
  232. },
  233. indentNumber: '',
  234. openLists: [],
  235. totalprice: '',
  236. addressId:''
  237. }
  238. },
  239. onLoad(e) {
  240. // console.log('``````', e)
  241. // this.indentType = e.index
  242. if(e.title) {
  243. this.title = false
  244. this.placeholder = '请填写'+ e.title + '的具体要求等'
  245. uni.setNavigationBarTitle({
  246.   title: e.title
  247. })
  248. }
  249. // 计算基础价格
  250. this.orderjc()
  251. // 获取服务类型
  252. this.getTypeList()
  253. // #ifdef H5
  254. let ua = navigator.userAgent.toLowerCase();
  255. if (ua.indexOf('micromessenger') !== -1) {
  256. this.openLists = [{
  257. image: '../static/icon_weixin.png',
  258. text: '微信',
  259. id: 2
  260. }];
  261. this.openWay = 2;
  262. } else {
  263. this.openLists = [{
  264. image: '../static/zhifubao.png',
  265. text: '支付宝',
  266. id: 1
  267. }];
  268. this.openWay = 1;
  269. }
  270. // #endif
  271. // #ifdef APP-PLUS
  272. this.openLists = [{
  273. image: '../static/zhifubao.png',
  274. text: '支付宝',
  275. id: 1
  276. }, {
  277. image: '../static/icon_weixin.png',
  278. text: '微信',
  279. id: 2
  280. }];
  281. this.openWay = 1;
  282. // #endif
  283. // #ifdef MP-WEIXIN
  284. this.openLists = [{
  285. image: '../static/icon_weixin.png',
  286. text: '微信',
  287. id: 2
  288. }];
  289. this.openWay = 2;
  290. // #endif
  291. },
  292. onShow() {
  293. console.log(this.addressId,'选择的地址id')
  294. this.addressId = this.addressId?this.addressId:uni.getStorageSync('addressId')
  295. if(this.addressId) {
  296. this.getAddress(this.addressId)
  297. }
  298. // this.citydata = uni.getStorageSync('closeAddress').citydata ? uni.getStorageSync('closeAddress').citydata : {}
  299. },
  300. methods: {
  301. getTypeList() {
  302. this.$Request.getT('/app/servicetype/selectServiceTypeList').then(res => {
  303. if (res.code == 0) {
  304. this.list = res.data
  305. }
  306. });
  307. },
  308. // 查询地址
  309. getAddress(e) {
  310. let data = {
  311. addressId: e
  312. }
  313. this.$Request.getT('/app/address/selectAddressById', data).then(res => {
  314. if (res.code == 0) {
  315. this.citydata = res.data
  316. uni.removeStorageSync('addressId')
  317. }
  318. });
  319. },
  320. // 跑腿协议
  321. binduserxieyi() {
  322. uni.navigateTo({
  323. url: '/my/setting/xieyi'
  324. })
  325. },
  326. // 服务类型
  327. typeconfirm(e) {
  328. console.log(e)
  329. this.placeholder = '请填写'+ e[0].label + '的具体要求等'
  330. this.citytype = e[0].label
  331. },
  332. bindtype() {
  333. this.typeshow = true
  334. },
  335. tabs(index) {
  336. this.current = index;
  337. },
  338. // switch打开或者关闭时触发,值为true或者false
  339. // 即使不监听此事件,this.checked此时也会相应的变成true或者false
  340. change(status) {
  341. // console.log(status);
  342. },
  343. bindtake() {
  344. uni.navigateTo({
  345. url: '/pages/closeaddress/closeaddress'
  346. })
  347. },
  348. bindclose() {
  349. uni.navigateTo({
  350. url: '/pages/takeaddress/takeaddress'
  351. })
  352. },
  353. // 注意返回值为一个数组,单列时取数组的第一个元素即可(只有一个元素)
  354. confirm(e) {
  355. console.log(e.timestamp)
  356. let curDate = new Date();
  357. this.year = curDate.getFullYear();
  358. this.month = curDate.getMonth();
  359. if (parseInt(curDate) >= parseInt(e.timestamp * 1000)) {
  360. uni.showToast({
  361. title: '请选择正确时间',
  362. icon: 'none'
  363. })
  364. } else {
  365. // this.selTime = e.timestamp
  366. this.buyTime = this.year + '-' + this.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + '00'
  367. this.forms.data = e.day + '号' + e.hour + ':' + e.minute
  368. }
  369. },
  370. onshowdata() {
  371. this.showdata = true
  372. },
  373. binddata() {
  374. this.showdata = false
  375. },
  376. // 自行配件
  377. confirms(e) {
  378. // console.log(e)
  379. this.forms.peijian = e[0].label
  380. },
  381. onshowm() {
  382. this.menshow = true
  383. },
  384. bindadd(index) {
  385. // console.log(index)
  386. // uni.navigateTo({
  387. // url: '/pages/closeaddress/closeaddress?index=' + index
  388. // })
  389. uni.navigateTo({
  390. url: '/my/address/index?add=1&addressType=' + index
  391. })
  392. },
  393. // 根据订单信息判断用户可用红包
  394. onshowmoney() {
  395. this.showmoney = true
  396. let data = {
  397. indentType: this.indentType, //订单类型
  398. indentBasicsMoney: this.price
  399. }
  400. this.$Request.postJson('/app/tbindent/findRedPacket', data).then(res => {
  401. // console.log(res)
  402. if (res.code === 0) {
  403. this.hongbao = res.data
  404. // console.log(this.hongbao)
  405. }
  406. });
  407. },
  408. // 判断红包使用id
  409. bindhongindex(id, price) {
  410. // console.log(id)
  411. this.redPacketId = id
  412. this.forms.hongbao = price
  413. this.showmoney = false
  414. let price1 = ( Number(this.price) - Number(this.forms.hongbao) ).toFixed(2)
  415. if(price1<=0) {
  416. price1 = 0.01
  417. }
  418. console.log(price1,'价格')
  419. this.totalprice = (Number(price1) + Number(this.forms.tip)).toFixed(2)
  420. console.log(this.totalprice)
  421. // this.totalprice = (Number(this.price || 0) - Number(this.forms.hongbao || 0) + Number(this.forms.tip || 0)).toFixed(2)
  422. if(this.totalprice<=0) {
  423. this.totalprice = 0.01
  424. }
  425. },
  426. //计算订单基础价格
  427. orderjc() {
  428. let data = {
  429. indentType: this.indentType //订单类型
  430. }
  431. this.$Request.postJson('/app/tbindent/basicsMoney', data).then(res => {
  432. // console.log(res)
  433. if (res.code === 0) {
  434. this.price = res.data.indentBasicsMoney
  435. this.cityPrice = res.data
  436. // console.log(this.cityPrice)
  437. }
  438. });
  439. },
  440. // 价格计算
  441. onKeyInput(e) {
  442. console.log(e)
  443. let price = (Number(this.price) - Number(this.forms.hongbao) ).toFixed(2)
  444. if(price<=0) {
  445. price = 0.01
  446. }
  447. this.totalprice = (Number(price) + Number(this.forms.tip)).toFixed(2)
  448. if(this.totalprice<=0) {
  449. this.totalprice = 0.01
  450. }
  451. },
  452. // 提交订单
  453. bindpay() {
  454. // this.totalprice = (Number(this.price || 0) - Number(this.forms.hongbao || 0) + Number(this.forms.tip || 0)).toFixed(2)
  455. console.log(this.totalprice)
  456. if (JSON.stringify(this.citydata) == '{}') {
  457. uni.showToast({
  458. title: '请填写服务地址',
  459. icon: 'none',
  460. duration: 2000
  461. });
  462. return
  463. }
  464. if (this.citytype == '' && this.title) {
  465. uni.showToast({
  466. title: '请选择服务类型',
  467. icon: 'none',
  468. duration: 2000
  469. });
  470. return
  471. }
  472. if (this.values == '') {
  473. uni.showToast({
  474. title: '请填写服务内容',
  475. icon: 'none',
  476. duration: 2000
  477. });
  478. return
  479. }
  480. // if (this.forms.peijian == '') {
  481. // uni.showToast({
  482. // title: '请选取自备配件',
  483. // icon: 'none',
  484. // duration: 2000
  485. // });
  486. // return
  487. // }
  488. if (this.check == false) {
  489. uni.showToast({
  490. title: '请勾选跑腿协议',
  491. icon: 'none',
  492. duration: 2000
  493. });
  494. return
  495. } else {
  496. let data = {
  497. // deliveryUserPhone: this.citydata.userPhone,
  498. // deliveryUserName: this.citydata.userName,
  499. // deliveryAddress: this.citydata.address,
  500. // deilveryAddressDetail: this.citydata.addressDetail,
  501. // deliveryAddressLatitude: this.citydata.addressLatitude,
  502. // deliveryAddressLongitude: this.citydata.addressLongitude,
  503. userName: this.citydata.userName, //收货人姓名
  504. userPhone: this.citydata.userPhone, //收货人电话
  505. userProvince: this.citydata.province, //收货人 省
  506. userCity: this.citydata.city, //收货人 市
  507. userDistrict: this.citydata.district, //收货人 区
  508. userAddressDetail: this.citydata.addressDetail, //收货人详细地址
  509. userLng: this.citydata.lng,
  510. userLat: this.citydata.lat,
  511. indentType: this.indentType,
  512. serviceType: this.citytype,
  513. serviceDetails: this.values,
  514. sendOutTime: this.forms.data,
  515. tool: this.forms.peijian,
  516. warrantyPeriod: this.forms.baoxiu,
  517. itemCode: "",
  518. remarks: "",
  519. tip: this.forms.tip,
  520. redPacketId: this.redPacketId,
  521. indentBasicsMoney: this.totalprice,
  522. modeOfPayment: "",
  523. errandMoney: this.cityPrice.errandMoney
  524. }
  525. this.$Request.postJson('/app/tbindent/addIndent', data).then(res => {
  526. // console.log(res)
  527. if (res.code == 0) {
  528. this.indentNumber = res.data.indentNumber
  529. // #ifdef MP-WEIXIN
  530. this.openWay= 2
  531. this.pay()
  532. // #endif
  533. // #ifndef MP-WEIXIN
  534. this.showpay = true
  535. // #endif
  536. }
  537. });
  538. }
  539. },
  540. selectWay: function(item) {
  541. this.openWay = item.id;
  542. },
  543. pay() {
  544. // let indentNumber = this.indentNumber
  545. // console.log(data)
  546. if (this.openWay == 0) {
  547. this.$queue.showToast('请选择支付方式!')
  548. return;
  549. }
  550. if (this.openWay == 2) {
  551. // #ifdef MP-WEIXIN
  552. uni.showLoading({
  553. title: '支付中...'
  554. });
  555. // 微信小程序支付
  556. this.$Request.postJson("/app/wxErrPay/wxPayJsApiOrder?indentNumber=" + this.indentNumber).then(res => {
  557. console.log(res, '********')
  558. if (res.code == 0) {
  559. console.log(this.openWay, '支付')
  560. uni.requestPayment({
  561. provider: 'wxpay',
  562. timeStamp: res.data.timestamp,
  563. nonceStr: res.data.noncestr,
  564. package: res.data.package,
  565. signType: res.data.signType,
  566. paySign: res.data.sign,
  567. success: function(suc) {
  568. console.log('success:' + JSON.stringify(suc));
  569. uni.showToast({
  570. title: '支付成功',
  571. icon: 'success'
  572. })
  573. uni.setStorageSync('current', 0)
  574. setTimeout(function() {
  575. uni.switchTab({
  576. url: '/pages/order/index',
  577. })
  578. }, 10)
  579. },
  580. fail: function(err) {
  581. console.log('fail:' + JSON.stringify(err));
  582. uni.showToast({
  583. title: '支付失败',
  584. icon: 'none'
  585. })
  586. uni.switchTab({
  587. url: '/pages/order/index'
  588. })
  589. }
  590. });
  591. }
  592. })
  593. // #endif
  594. // #ifdef H5
  595. let ua = navigator.userAgent.toLowerCase();
  596. if (ua.indexOf('micromessenger') !== -1) { //微信里打开
  597. this.$Request.postJson('/app/wxPay/wxPayMpOrder?indentNumber=' + this.indentNumber)
  598. .then(res => {
  599. console.log(res)
  600. if (res.code == 0) {
  601. console.log()
  602. this.callPay(res.data);
  603. } else {
  604. uni.showToast({
  605. icon: 'none',
  606. title: '支付失败!'
  607. });
  608. }
  609. });
  610. } else { //不是微信打开
  611. this.$Request.postJson('/app/wxPay/wxPayMpOrder?indentNumber=' + this.indentNumber)
  612. .then(
  613. res => {
  614. if (res.code == 0) {
  615. console.log('....11111111.....', res.data)
  616. const div = document.createElement('div')
  617. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  618. console.log('....2.....', res.data)
  619. document.body.appendChild(div)
  620. console.log('....33333.....', document.forms[0])
  621. document.forms[0].submit()
  622. } else {
  623. uni.showToast({
  624. icon: 'none',
  625. title: '支付失败!'
  626. });
  627. }
  628. });
  629. }
  630. // #endif
  631. } else {
  632. // APP支付宝支付
  633. this.$Request.postJson("/app/aliPay/payH5Order?indentNumber=" + this.indentNumber)
  634. .then(
  635. ret => {
  636. console.log(ret)
  637. // const div = document.createElement('div')
  638. // div.innerHTML = ret.data //此处form就是后台返回接收到的数据
  639. // document.body.appendChild(div)
  640. // document.forms[0].submit()
  641. this.isCheckPay(ret.code, 'alipay', ret.data);
  642. });
  643. }
  644. },
  645. callPay: function(response) {
  646. if (typeof WeixinJSBridge === "undefined") {
  647. if (document.addEventListener) {
  648. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  649. } else if (document.attachEvent) {
  650. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  651. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  652. }
  653. } else {
  654. this.onBridgeReady(response);
  655. }
  656. },
  657. onBridgeReady: function(response) {
  658. let that = this;
  659. if (!response.package) {
  660. return;
  661. }
  662. WeixinJSBridge.invoke(
  663. 'getBrandWCPayRequest', {
  664. "appId": response.appid, //公众号名称,由商户传入
  665. "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
  666. "nonceStr": response.noncestr, //随机串
  667. "package": response.package,
  668. "signType": response.signType, //微信签名方式:
  669. "paySign": response.sign //微信签名
  670. },
  671. function(res) {
  672. console.log(res, '/*-/*-/*-')
  673. if (res.err_msg === "get_brand_wcpay_request:ok") {
  674. // 使用以上方式判断前端返回,微信团队郑重提示:
  675. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  676. uni.showLoading({
  677. title: '支付成功'
  678. });
  679. setTimeout(function() {
  680. uni.hideLoading();
  681. uni.switchTab({
  682. url: '../order/order'
  683. })
  684. }, 1000);
  685. } else {
  686. uni.hideLoading();
  687. }
  688. WeixinJSBridge.log(response.err_msg);
  689. }
  690. );
  691. },
  692. isCheckPay(status, name, order) {
  693. if (status == 0) {
  694. this.setPayment(name, order);
  695. } else {
  696. uni.hideLoading();
  697. uni.showToast({
  698. title: '支付信息有误',
  699. icon: 'none'
  700. });
  701. }
  702. },
  703. setPayment(name, order) {
  704. console.log('*-*-*')
  705. uni.requestPayment({
  706. provider: name,
  707. orderInfo: order, //微信、支付宝订单数据
  708. success: function(res) {
  709. console.log(res)
  710. uni.hideLoading();
  711. uni.showLoading({
  712. title: '支付成功'
  713. });
  714. uni.setStorageSync('current', 0)
  715. setTimeout(function() {
  716. uni.switchTab({
  717. url: '/pages/order/order',
  718. })
  719. }, 10)
  720. },
  721. fail: function(err) {
  722. console.log(err)
  723. uni.hideLoading();
  724. },
  725. complete() {
  726. uni.hideLoading();
  727. }
  728. });
  729. },
  730. }
  731. }
  732. </script>
  733. <style>
  734. body {
  735. background: #F2EDED;
  736. }
  737. /* #ifndef MP-WEIXIN */
  738. page {
  739. background: #F2EDED;
  740. }
  741. /* #endif */
  742. /* 取件时间弹框 */
  743. .popup_data {
  744. height: 600upx;
  745. width: 100%;
  746. position: relative;
  747. }
  748. .data_title {
  749. width: 92%;
  750. margin: 0 auto;
  751. font-size: 34upx;
  752. line-height: 110upx;
  753. font-weight: bold;
  754. letter-spacing: 2upx;
  755. position: relative;
  756. top: 0upx;
  757. z-index: 99991;
  758. }
  759. .data_btn {
  760. position: absolute;
  761. bottom: 30upx;
  762. width: 100%;
  763. z-index: 99992;
  764. }
  765. .btn {
  766. width: 90%;
  767. margin: 0 auto;
  768. height: 45upx;
  769. color: white;
  770. background: #FF7F00;
  771. border-radius: 22upx;
  772. text-align: center;
  773. line-height: 90upx;
  774. letter-spacing: 2upx;
  775. }
  776. .u-close {
  777. position: absolute;
  778. z-index: 999999 !important;
  779. }
  780. .u-picker-body {
  781. height: 355upx !important;
  782. }
  783. /* .u-picker-header {
  784. position: relative !important;
  785. top: 138upx;
  786. z-index: 99992;
  787. } */
  788. /* 物品信息弹框 */
  789. .popup_info {
  790. height: 1140upx;
  791. width: 100%;
  792. position: relative;
  793. }
  794. .data_items {
  795. width: 100%;
  796. }
  797. .item_box {
  798. width: 90%;
  799. margin: 0 auto;
  800. }
  801. .item_btn {
  802. border: 1upx solid #cccccc;
  803. border-radius: 80upx;
  804. width: 200upx;
  805. height: 80upx;
  806. text-align: center;
  807. line-height: 80upx;
  808. font-size: 31rpx;
  809. margin-right: 10upx;
  810. margin-left: 10upx;
  811. margin-bottom: 20upx;
  812. }
  813. .item_btn:active {
  814. background: #ffd9b3;
  815. border: 2upx solid #ff7f00;
  816. }
  817. .item_type {
  818. display: flex;
  819. flex-wrap: wrap;
  820. margin-top: 20upx;
  821. }
  822. /* 物品保价弹框 */
  823. .valua_icon {
  824. width: 90%;
  825. position: absolute;
  826. bottom: 140upx;
  827. left: 42upx;
  828. }
  829. .input {
  830. width: 90%;
  831. margin: 0 auto;
  832. }
  833. .u-input--border {
  834. border-radius: 12rupx;
  835. border: 2upx solid #F2F2F2 !important;
  836. background: #F2F2F2 !important;
  837. }
  838. .input_bg {
  839. width: 90%;
  840. margin: 0 auto;
  841. position: relative;
  842. }
  843. .input_bg image {
  844. width: 100%;
  845. height: 90upx;
  846. }
  847. .input_bg text {
  848. position: absolute;
  849. top: 30upx;
  850. left: 36upx;
  851. color: #FF7F00;
  852. font-size: 31rpx;
  853. }
  854. /* 红包弹框 */
  855. .popup_money {
  856. /* height: 400upx; */
  857. width: 100%;
  858. height: 630rpx;
  859. position: relative;
  860. background: #F2EDED;
  861. padding-bottom: 45rpx;
  862. /* #ifndef MP-WEIXIN */
  863. height: 680rpx;
  864. /* #endif */
  865. }
  866. .uni-scroll-view,
  867. .uni-scroll-view-content {
  868. position: relative;
  869. width: 100%;
  870. height: 100%;
  871. background: #F2EDED;
  872. }
  873. .image_box {
  874. width: 40%;
  875. margin: 0 auto;
  876. margin-bottom: 110rpx;
  877. }
  878. .u-drawer-bottom {
  879. background-color: #FAF7F5 !important;
  880. }
  881. .money_box {
  882. width: 93%;
  883. margin: 0 auto;
  884. background: #ffffff;
  885. border-radius: 16upx;
  886. height: 250upx;
  887. margin-bottom: 20upx;
  888. }
  889. .box_tit {
  890. width: 90%;
  891. margin: 0 auto;
  892. height: 80upx;
  893. display: flex;
  894. }
  895. .money_name {
  896. flex: 1;
  897. display: flex;
  898. justify-content: left;
  899. align-items: center;
  900. font-size: 31rpx;
  901. font-weight: bold;
  902. letter-spacing: 2upx;
  903. }
  904. .money_price {
  905. flex: 1;
  906. display: flex;
  907. justify-content: flex-end;
  908. align-items: center;
  909. font-size: 36upx;
  910. font-weight: bold;
  911. color: red;
  912. }
  913. .money_data {
  914. color: #999999;
  915. font-size: 22upx;
  916. width: 90%;
  917. margin: 0 auto;
  918. margin-top: -10upx;
  919. }
  920. .u-line {
  921. width: 90% !important;
  922. border-bottom-width: 3upx !important;
  923. margin: 0 auto !important;
  924. margin-top: 24upx !important;
  925. margin-bottom: 24upx !important;
  926. }
  927. .box_bottom {
  928. width: 90%;
  929. margin: 0 auto;
  930. display: flex;
  931. height: 40upx;
  932. }
  933. .money_use {
  934. flex: 1;
  935. color: #999999;
  936. font-size: 22upx;
  937. display: flex;
  938. justify-content: left;
  939. align-items: center;
  940. }
  941. .lj_use {
  942. width: 160upx;
  943. border: 1upx solid #FF7F00;
  944. color: #FF7F00;
  945. text-align: center;
  946. line-height: 46upx;
  947. border-radius: 42upx;
  948. font-size: 20upx;
  949. }
  950. .help_send {
  951. width: 100%;
  952. }
  953. .content {
  954. margin-top: -380upx;
  955. position: relative;
  956. z-index: 999;
  957. }
  958. .part_one {
  959. width: 95%;
  960. margin: 0 auto;
  961. height: 225rpx;
  962. background: #ffffff;
  963. border-radius: 20upx;
  964. margin-top: 20upx;
  965. }
  966. .pay_tit {
  967. width: 95%;
  968. margin: 0 auto;
  969. /* height: 200upx; */
  970. position: relative;
  971. }
  972. .pay_name {
  973. font-size: 32rpx;
  974. font-weight: bold;
  975. width: 95%;
  976. margin: 0 auto;
  977. letter-spacing: 2upx;
  978. padding-top: 30upx;
  979. }
  980. .pay_set {
  981. color: #333333;
  982. font-size: 24upx;
  983. width: 95%;
  984. margin: 0 auto;
  985. /* margin-top: 20upx; */
  986. }
  987. .part_two {
  988. width: 95%;
  989. margin: 0 auto;
  990. /* height: 235rpx; */
  991. background: #ffffff;
  992. border-radius: 20upx;
  993. margin-top: 20upx;
  994. }
  995. .u-form {
  996. margin-top: -22rpx;
  997. }
  998. .service_box {
  999. display: flex;
  1000. justify-content: space-between;
  1001. align-items: center;
  1002. width: 94%;
  1003. margin: 0 auto;
  1004. }
  1005. .service_address {
  1006. flex: 3;
  1007. margin-left: 14upx;
  1008. }
  1009. .service_name {
  1010. width: 100%;
  1011. margin-top: 30upx;
  1012. margin-bottom: 16upx;
  1013. font-size: 32rpx;
  1014. }
  1015. .service_dd {
  1016. font-size: 28rpx;
  1017. }
  1018. .service_dd text {
  1019. margin-left: 20upx;
  1020. }
  1021. .service_icon {
  1022. /* flex: 1; */
  1023. display: flex;
  1024. justify-content: flex-end;
  1025. align-items: center;
  1026. color: #CCCCCC;
  1027. }
  1028. .part_three {
  1029. width: 95%;
  1030. margin: 0 auto;
  1031. /* height: 350rpx; */
  1032. background: #ffffff;
  1033. border-radius: 20upx;
  1034. margin-top: 45rpx;
  1035. }
  1036. .u-form-item__body {
  1037. position: relative !important;
  1038. }
  1039. .u-form-item--left {
  1040. position: absolute !important;
  1041. top: 30upx;
  1042. left: 15rpx;
  1043. font-size: 31upx;
  1044. font-weight: bold;
  1045. letter-spacing: 2upx;
  1046. }
  1047. .u-form-item--right__content {
  1048. margin-right: 20upx !important;
  1049. }
  1050. .u-form-item {
  1051. line-height: 20upx !important;
  1052. }
  1053. .u-form-item {
  1054. padding: 20rpx 0 !important;
  1055. }
  1056. .u-input__input {
  1057. font-size: 44rupx !important;
  1058. }
  1059. .u-input__input {
  1060. font-size: 31rpx !important;
  1061. }
  1062. .part_four {
  1063. width: 95%;
  1064. padding: 20rpx 0rpx;
  1065. background: #ffffff;
  1066. margin: 0 auto;
  1067. border-radius: 20upx;
  1068. display: flex;
  1069. margin-top: 20upx;
  1070. }
  1071. .service_type {
  1072. flex: 1;
  1073. /* display: flex; */
  1074. /* justify-content: left; */
  1075. /* align-items: center; */
  1076. margin-left: 40upx;
  1077. font-size: 31rpx;
  1078. font-weight: bold;
  1079. }
  1080. .service_you {
  1081. /* flex: 1; */
  1082. display: flex;
  1083. justify-content: flex-end;
  1084. align-items: center;
  1085. margin-right: 20upx;
  1086. color: #CCCCCC;
  1087. }
  1088. .content_sure {
  1089. display: flex;
  1090. align-items: center;
  1091. margin-bottom: 160rpx;
  1092. margin-left: 15px;
  1093. margin-top: 10px;
  1094. /* #ifndef MP-WEIXIN */
  1095. /* margin-bottom: 200px; */
  1096. /* #endif */
  1097. }
  1098. .u-checkbox__label {
  1099. font-size: 28rpx !important;
  1100. letter-spacing: 2upx;
  1101. color: #888888 !important;
  1102. }
  1103. .tabbar {
  1104. width: 100%;
  1105. height: 100upx;
  1106. background: #ffffff;
  1107. position: fixed;
  1108. bottom: 0upx;
  1109. left: 0upx;
  1110. right: 0upx;
  1111. display: flex;
  1112. /* #ifndef MP-WEIXIN */
  1113. position: fixed;
  1114. bottom: 0upx;
  1115. left: 0upx;
  1116. right: 0upx;
  1117. /* #endif */
  1118. z-index: 99;
  1119. }
  1120. .tabbar_price {
  1121. flex: 1;
  1122. display: flex;
  1123. justify-content: left;
  1124. align-items: center;
  1125. font-size: 31rpx;
  1126. font-weight: bold;
  1127. margin-left: 40upx;
  1128. }
  1129. .tabbar_price text {
  1130. color: #FF3333;
  1131. font-size: 36upx;
  1132. font-weight: 500;
  1133. }
  1134. .tabbar_btn {
  1135. flex: 1;
  1136. display: flex;
  1137. justify-content: center;
  1138. align-items: center;
  1139. }
  1140. .but {
  1141. background: #FF7F00;
  1142. width: 200rpx;
  1143. height: 70rpx;
  1144. text-align: center;
  1145. line-height: 70rpx;
  1146. border-radius: 60rpx;
  1147. color: white;
  1148. font-size: 24rpx;
  1149. }
  1150. .actclass {
  1151. background-color: #FFD9B3;
  1152. }
  1153. /* 支付弹框 */
  1154. .popup_pay {
  1155. width: 100%;
  1156. }
  1157. .pay_btns {
  1158. width: 90%;
  1159. margin: 20rpx auto 40rpx;
  1160. text-align: center;
  1161. background: #FF7F00;
  1162. height: 80rpx;
  1163. border-radius: 16rpx;
  1164. color: #ffffff;
  1165. line-height: 80rpx;
  1166. }
  1167. </style>