editor.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. <template>
  2. <view>
  3. <view class="text-white padding bg radius margin">
  4. <u-form :model="form" ref="uForm" label-position="top" :label-style='lableStyle'>
  5. <u-form-item label="标题">
  6. <u-input v-model="form.myLevel" placeholder="请填写服务项目标题" />
  7. </u-form-item>
  8. <u-form-item label="服务类型">
  9. <view v-if="game == ''" @click="openJn(game)" style="color: #cccccc;">
  10. 选择服务类型(多选)
  11. </view>
  12. <view v-else style="display: inline-flex;">
  13. <view v-for="(item,index) in game" @click="openJn(game)"
  14. style="background: #2FB57A;margin-right: 15rpx;color: #FFFFFF;padding: 0rpx 15rpx;border-radius: 15rpx;">
  15. {{item.gameName?item.gameName:item}}
  16. </view>
  17. </view>
  18. </u-form-item>
  19. <u-form-item label="服务时长">
  20. <u-input v-model="form.orderLevel" placeholder="请填写(必填)" disabled="true" @click="JYshow = true" />
  21. </u-form-item>
  22. <u-form-item label="期望薪资(月薪)">
  23. <u-input v-model="form.money" type="number" placeholder="请填写(必填)" />
  24. </u-form-item>
  25. </u-form>
  26. </view>
  27. <view class="text-white padding bg radius margin ">
  28. <view class="text-lg">自我介绍</view>
  29. <view class="margin-tb-sm">
  30. <u-input v-model="form.describes" type="textarea" height="200" placeholde="请描述一下您的特长" maxlengt="200"
  31. :clearable="false" />
  32. </view>
  33. <view class="text-lg margin-top-sm">头像上传(可多张)</view>
  34. <view class="flex" style="overflow: hidden;flex-direction: initial;">
  35. <view class="margin-top flex margin-right-sm" v-if="headImg.length">
  36. <view class="flex" style="width: 200rpx;height: 200rpx;margin-right: 10rpx;position: relative;"
  37. v-for="(image,index) in headImg" :key="index">
  38. <image :src="image" style="width: 100%;height: 100%;"></image>
  39. <view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;"
  40. @click="headImgremove(index)">
  41. <u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="margin-top" @click="addImage(1)" v-if="headImg.length<=2">
  46. <view style="width: 200rpx;height: 200rpx;background: #f4f5f6;"
  47. class="flex justify-center align-center">
  48. <view>
  49. <view class="text-center">
  50. <image src="../../static/images/my/add.png" style="width: 65rpx;height: 55rpx;">
  51. </image>
  52. </view>
  53. <view class="text-center">添加图片</view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="text-lg margin-top-sm">持有资质证书 (可多张)</view>
  59. <view class="flex" style="overflow: hidden;flex-wrap: wrap;">
  60. <view class="margin-top flex margin-right-sm flex-wrap" v-if="certificateImg.length">
  61. <view class="flex" style="width: 200rpx;height: 200rpx;margin-right: 2rpx;position: relative;"
  62. v-for="(image,index) in certificateImg" :key="index">
  63. <image :src="image" style="width: 100%;height: 100%;"></image>
  64. <view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;"
  65. @click="removeImg(index)">
  66. <u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="margin-top" @click="addImages(2)" v-if="certificateImg.length<=2">
  71. <view style="width: 200rpx;height: 200rpx;background: #f4f5f6;"
  72. class="flex justify-center align-center">
  73. <view>
  74. <view class="text-center">
  75. <image src="../../static/images/my/add.png" style="width: 65rpx;height: 55rpx;">
  76. </image>
  77. </view>
  78. <view class="text-center">添加图片</view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="margin-lr bg radius " style="margin-bottom: 240rpx;">
  85. <view class="padding">
  86. <view style="color: #2FB57A;">缴纳保证金</view>
  87. <view class="flex justify-between align-center" style="line-height: 60rpx;">
  88. <view style="color: #999999;" class="text-sm">满足一定条件即可申请返还保证金</view>
  89. <view style="color: #F1413D;">¥{{money}}</view>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="tabbar">
  94. <view>
  95. 支付:<text style="color: #F1413D;">¥{{money}}</text>
  96. </view>
  97. <view>
  98. <u-button v-if="id" @click="update" class="margin-top" :custom-style="customStyle" shape="circle"
  99. :hair-line="false">发布并支付</u-button>
  100. <u-button v-else @click="submit" class="margin-top" :custom-style="customStyle" shape="circle"
  101. :hair-line="false">发布并支付</u-button>
  102. </view>
  103. </view>
  104. <!-- 经验筛选 -->
  105. <u-select v-model="JYshow" :list="list" @confirm="Getjy"></u-select>
  106. <!-- 地区选择 -->
  107. <u-picker v-model="Dqshow" mode="region" @confirm="bindRegion"></u-picker>
  108. <u-popup v-model="show" mode="bottom" border-radius="14" :closeable="true">
  109. <view class="fl_pop">
  110. <view class="flex flex-wrap" style="padding: 100rpx 60rpx;margin-bottom: 50rpx;">
  111. <view v-for="(item,index) in gameList" :key="index" class="flex margin-right-sm"
  112. @click="bindList(index,item)">
  113. <text class="tabBox margin-top-xs"
  114. :class="item.ischeck==true?'btnnum':''">{{item.gameName}}</text>
  115. </view>
  116. <u-button @click="bindGame()" :custom-style="customStyle1">确定</u-button>
  117. </view>
  118. </view>
  119. </u-popup>
  120. <!-- 支付方式 -->
  121. <u-popup v-model="showpay" mode="bottom" :closeable="closeable">
  122. <view class="popup_pay">
  123. <view style="background-color: #fff;">
  124. <view style="padding: 0 20upx;margin-top: 60rpx;margin-bottom: 20rpx;">
  125. <view
  126. style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;justify-content: center;"
  127. v-for="(item,index) in openLists" :key='index'>
  128. <image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;">
  129. </image>
  130. <view style="font-size: 30upx;margin-left: 20upx;width: 70%;">
  131. {{item.text}}
  132. </view>
  133. <radio-group name="openWay" style="margin-left: 45upx;" @tap='selectWay(item)'>
  134. <label class="tui-radio">
  135. <radio color="#2FB57A" :checked="openWay === item.id ? true : false" />
  136. </label>
  137. </radio-group>
  138. </view>
  139. </view>
  140. </view>
  141. <view class="pay_btn" @click="pay()">确认支付</view>
  142. </view>
  143. </u-popup>
  144. <!-- <u-action-sheet :list="actionSheetList" v-model="actionSheetShow" @click="actionSheetCallback"></u-action-sheet> -->
  145. </view>
  146. </template>
  147. <script>
  148. import configdata from '@/common/config.js';
  149. import jsfunRecord from '../components/jc-record/jc-record.vue'
  150. export default {
  151. components: {
  152. jsfunRecord
  153. },
  154. data() {
  155. return {
  156. form: {
  157. myLevel: '',
  158. gameId: '',
  159. orderLevel: '',
  160. money: '',
  161. describes: '',
  162. //头像上传
  163. headImg: [],
  164. //资质证书
  165. certificateImg: [],
  166. city: '',
  167. id: 0,
  168. //地区
  169. region: ''
  170. },
  171. disabled: false,
  172. lableStyle: {
  173. fontSize: '32rpx'
  174. },
  175. customStyle: {
  176. backgroundColor: '#2FB57A',
  177. color: '#FFFFFF',
  178. border: 0
  179. },
  180. status: 1,
  181. customStyle1: {
  182. color: '#FFFFFF',
  183. position: "fixed",
  184. bottom: "15rpx",
  185. left: "0rpx",
  186. right: "0rpx",
  187. margin: "0rpx 50rpx",
  188. backgroundColor: '#2FB57A',
  189. },
  190. selarr: [],
  191. show: false,
  192. gameList: [],
  193. game: '',
  194. checked: false,
  195. disabled: false,
  196. number: 0,
  197. id: '',
  198. //地区选择
  199. Dqshow: false,
  200. //头像上传
  201. headImg: [],
  202. //资质证书
  203. certificateImg: [],
  204. region: '',
  205. count: 0,
  206. JYshow: false,
  207. list: [{
  208. value: '1',
  209. label: '60分钟'
  210. }, {
  211. value: '2',
  212. label: '90分钟'
  213. }, {
  214. value: '3',
  215. label: '120分钟'
  216. }, {
  217. value: '4',
  218. label: '3小时'
  219. },
  220. {
  221. value: '5',
  222. label: '4小时'
  223. }, {
  224. value: '6',
  225. label: '5小时'
  226. }
  227. ],
  228. money: 0,
  229. showpay: false,
  230. openLists: [],
  231. openWay: 1,
  232. closeable: true
  233. }
  234. },
  235. onLoad() {
  236. this.form.city = uni.getStorageSync('city')
  237. this.form.latitude = uni.getStorageSync('latitude')
  238. this.form.longitude = uni.getStorageSync('longitude')
  239. this.getData(1)
  240. this.getGameList()
  241. // #ifdef APP
  242. this.openLists = [{
  243. image: '../../static/images/icon_weixin.png',
  244. text: '微信',
  245. id: 1
  246. }, {
  247. image: '../../static/images/zhifubao.png',
  248. text: '支付宝',
  249. id: 2
  250. }],
  251. this.openWay = 1;
  252. // #endif
  253. // #ifdef MP-WEIXIN
  254. this.openLists = [{
  255. image: '../../static/images/icon_weixin.png',
  256. text: '微信',
  257. id: 1
  258. }],
  259. this.openWay = 1;
  260. // #endif
  261. // #ifdef H5
  262. this.openLists = [{
  263. image: '../../static/images/zhifubao.png',
  264. text: '支付宝',
  265. id: 2
  266. }]
  267. this.openWay = 2;
  268. // #endif
  269. },
  270. onShow() {
  271. this.Getmoney()
  272. },
  273. methods: {
  274. // 保证金
  275. Getmoney() {
  276. this.$Request.get("/app/common/type/239").then(res => {
  277. console.log(res)
  278. if (res.code == 0) {
  279. this.money = res.data.value
  280. }
  281. });
  282. },
  283. //经验筛选
  284. Getjy(e) {
  285. console.log(e);
  286. this.form.orderLevel = e[0].label
  287. },
  288. //头像删除
  289. headImgremove(){
  290. this.headImg.splice(index, 1)
  291. },
  292. //资质证书删除
  293. removeImg(index) {
  294. this.certificateImg.splice(index, 1)
  295. },
  296. // 技能列表
  297. bindList(index, item) {
  298. console.log(index)
  299. if (this.selarr.length > 1 && item.ischeck == false) {
  300. uni.showToast({
  301. title: '最多选择2个技能',
  302. icon: 'none'
  303. })
  304. return
  305. }
  306. if (item.ischeck == false) {
  307. item.ischeck = true;
  308. this.selarr.push(item)
  309. } else {
  310. item.ischeck = false;
  311. let index11 = this.selarr.indexOf(index)
  312. this.selarr.splice(index11, 1)
  313. }
  314. this.selarr = this.selarr;
  315. },
  316. openJn(item) {
  317. console.log(item)
  318. this.show = true
  319. // item.ischeck = true
  320. },
  321. //地区开关
  322. bindOpen() {
  323. this.Dqshow = true
  324. },
  325. //地区选择
  326. bindRegion(e) {
  327. console.log(e)
  328. this.region = e.province.label + e.city.label + e.area.label
  329. this.form.region = e.province.label + ',' + e.city.label + ',' + e.area.label
  330. },
  331. // 服务类型选中提交
  332. bindGame() {
  333. this.game = this.selarr
  334. let gameId = "";
  335. for (var game in this.selarr) {
  336. gameId = gameId + "," + this.selarr[game].gameName
  337. }
  338. gameId = gameId.substring(1, gameId.length);
  339. this.form.gameId = gameId
  340. this.show = false
  341. },
  342. select(e) {
  343. this.status = e
  344. },
  345. // 图片上传
  346. addImages(e) {
  347. let that = this
  348. uni.chooseImage({
  349. count: 6,
  350. sourceType: ['album', 'camera'],
  351. success: res => {
  352. for (let i = 0; i < res.tempFilePaths.length; i++) {
  353. that.$queue.showLoading("上传中...");
  354. uni.uploadFile({ // 上传接口
  355. url: that.config("APIHOST1") + '/alioss/upload', //真实的接口地址
  356. filePath: res.tempFilePaths[i],
  357. name: 'file',
  358. success: (uploadFileRes) => {
  359. if (e == 1) {
  360. // that.form.homepageImg = JSON.parse(uploadFileRes.data).data
  361. that.headImg.push(JSON.parse(uploadFileRes.data).data)
  362. } else if (e == 2) {
  363. if (that.certificateImg.length <= 5) {
  364. that.certificateImg.push(JSON.parse(uploadFileRes.data)
  365. .data)
  366. }
  367. }
  368. uni.hideLoading();
  369. }
  370. });
  371. }
  372. }
  373. })
  374. },
  375. addImage(e) {
  376. let that = this
  377. uni.chooseImage({
  378. count: 3,
  379. sourceType: ['album', 'camera'],
  380. success: res => {
  381. for (let i = 0; i < res.tempFilePaths.length; i++) {
  382. that.$queue.showLoading("上传中...");
  383. uni.uploadFile({ // 上传接口
  384. url: that.config("APIHOST1") + '/alioss/upload', //真实的接口地址
  385. filePath: res.tempFilePaths[i],
  386. name: 'file',
  387. success: (uploadFileRes) => {
  388. if (e == 1) {
  389. that.headImg.push(JSON.parse(uploadFileRes.data).data)
  390. }
  391. uni.hideLoading();
  392. }
  393. });
  394. }
  395. }
  396. })
  397. },
  398. config: function(name) {
  399. var info = null;
  400. if (name) {
  401. var name2 = name.split("."); //字符分割
  402. if (name2.length > 1) {
  403. info = configdata[name2[0]][name2[1]] || null;
  404. } else {
  405. info = configdata[name] || null;
  406. }
  407. if (info == null) {
  408. let web_config = cache.get("web_config");
  409. if (web_config) {
  410. if (name2.length > 1) {
  411. info = web_config[name2[0]][name2[1]] || null;
  412. } else {
  413. info = web_config[name] || null;
  414. }
  415. }
  416. }
  417. }
  418. return info;
  419. },
  420. // 发布
  421. submit() {
  422. this.form.headImg = this.headImg
  423. this.form.headImg = this.form.headImg.toString();
  424. this.form.certificateImg = this.certificateImg
  425. this.form.certificateImg = this.form.certificateImg.toString();
  426. if (!this.form.myLevel) {
  427. uni.showToast({
  428. title: '请填写发布标题',
  429. icon: 'none',
  430. duration: 1000
  431. })
  432. return
  433. }
  434. if (this.game == '') {
  435. uni.showToast({
  436. title: '请选择服务类型',
  437. icon: 'none',
  438. duration: 1000
  439. })
  440. return
  441. }
  442. if (!this.form.orderLevel) {
  443. uni.showToast({
  444. title: '请选择服务时长',
  445. icon: 'none',
  446. duration: 1000
  447. })
  448. return
  449. }
  450. if (!this.form.money) {
  451. uni.showToast({
  452. title: '请填写期望薪资',
  453. icon: 'none',
  454. duration: 1000
  455. })
  456. return
  457. }
  458. if (!this.form.describes) {
  459. uni.showToast({
  460. title: '请填写自我介绍',
  461. icon: 'none',
  462. duration: 1000
  463. })
  464. return
  465. }
  466. if (!this.form.headImg) {
  467. uni.showToast({
  468. title: '请上传头像',
  469. icon: 'none',
  470. duration: 1000
  471. })
  472. return
  473. }
  474. if (!this.form.certificateImg) {
  475. uni.showToast({
  476. title: '请上传资质证书',
  477. icon: 'none',
  478. duration: 1000
  479. })
  480. return
  481. }
  482. console.log(this.form)
  483. this.form.id = ''
  484. this.$Request.get("/app/orderTaking/insertOrderTaking", this.form).then(res => {
  485. if (res.code == 0) {
  486. uni.showToast({
  487. title: res.msg,
  488. icon: 'none'
  489. })
  490. setTimeout(function() {
  491. uni.navigateTo({
  492. url: '/my/publish/index'
  493. })
  494. }, 1000)
  495. } else {
  496. uni.showToast({
  497. title: res.msg,
  498. icon: 'none'
  499. })
  500. }
  501. });
  502. },
  503. // 重新编辑
  504. update() {
  505. this.form.headImg = this.headImg
  506. this.form.headImg = this.form.headImg.toString();
  507. this.form.certificateImg = this.certificateImg
  508. this.form.certificateImg = this.form.certificateImg.toString();
  509. if (!this.form.myLevel) {
  510. uni.showToast({
  511. title: '请填写发布标题',
  512. icon: 'none',
  513. duration: 1000
  514. })
  515. return
  516. }
  517. if (this.game == '') {
  518. uni.showToast({
  519. title: '请选择服务类型',
  520. icon: 'none',
  521. duration: 1000
  522. })
  523. return
  524. }
  525. if (!this.form.orderLevel) {
  526. uni.showToast({
  527. title: '请选择服务时长',
  528. icon: 'none',
  529. duration: 1000
  530. })
  531. return
  532. }
  533. if (!this.form.money) {
  534. uni.showToast({
  535. title: '请填写期望薪资',
  536. icon: 'none',
  537. duration: 1000
  538. })
  539. return
  540. }
  541. if (!this.form.describes) {
  542. uni.showToast({
  543. title: '请填写自我介绍',
  544. icon: 'none',
  545. duration: 1000
  546. })
  547. return
  548. }
  549. if (!this.form.headImg) {
  550. uni.showToast({
  551. title: '请上传头像',
  552. icon: 'none',
  553. duration: 1000
  554. })
  555. return
  556. }
  557. if (!this.form.certificateImg) {
  558. uni.showToast({
  559. title: '请上传资质证书',
  560. icon: 'none',
  561. duration: 1000
  562. })
  563. return
  564. }
  565. this.$Request.get("/app/orderTaking/updateTakingOrder", this.form).then(res => {
  566. if (res.code == 0) {
  567. uni.showToast({
  568. title: '编辑成功',
  569. icon: 'none'
  570. })
  571. setTimeout(function() {
  572. // uni.navigateBack()
  573. uni.navigateTo({
  574. url: '/my/publish/index'
  575. })
  576. }, 1000)
  577. }
  578. });
  579. },
  580. // 获取游戏列表
  581. getGameList() {
  582. this.$Request.get("/app/appGame/queryGameName").then(res => {
  583. if (res.code == 0) {
  584. res.data.forEach(res => {
  585. res.label = res.gameName
  586. res.value = res.id
  587. res.ischeck = false
  588. })
  589. if (this.id) {
  590. for (var i = 0; i < res.data.length; i++) {
  591. for (var a = 0; a < this.game.length; a++) {
  592. if (res.data[i].gameName == this.game[a]) {
  593. res.data[i].ischeck = true
  594. }
  595. }
  596. }
  597. }
  598. this.gameList = res.data
  599. console.log(this.gameList)
  600. }
  601. });
  602. },
  603. getData(e) {
  604. let data = {
  605. id: e
  606. }
  607. this.$Request.get("/app/orderTaking/queryTakingOrder", data).then(res => {
  608. if (res.code == 0) {
  609. this.game = res.data.gameId.split(',')
  610. this.form.gameId = res.data.gameId
  611. this.form.myLevel = res.data.myLevel
  612. this.form.region = res.data.region
  613. this.form.money = res.data.oldMoney
  614. this.form.describes = res.data.describes
  615. this.form.headImg = res.data.headImg ? res.data.headImg : ''
  616. this.headImg = res.data.headImg.split(',') ? res.data.headImg.split(',') : ''
  617. this.form.certificateImg = res.data.certificateImg ? res.data.certificateImg : ''
  618. this.certificateImg = res.data.certificateImg.split(',') ? res.data.certificateImg.split(
  619. ',') : ''
  620. this.form.authentication = res.data.authentication
  621. this.form.orderLevel = res.data.orderLevel
  622. this.region = res.data.region
  623. }
  624. });
  625. },
  626. pay() {
  627. let userId = uni.getStorageSync('userId')
  628. data = {
  629. name: this.form.name,
  630. idNumber: this.form.idNumber,
  631. birthdate: this.form.birth,
  632. sex: this.sex,
  633. phone: this.form.phone,
  634. front: this.form.front,
  635. back: this.form.back,
  636. remek: this.form.remek,
  637. infantImg: this.form.infantImg,
  638. infantImgs: this.form.infantImgs,
  639. classify: this.classify,
  640. userId: userId
  641. }
  642. console.log(data, 'pppp1')
  643. this.showpay = false
  644. if (this.openWay == 1) { //微信支付
  645. // #ifdef MP-WEIXIN
  646. this.$Request.postJson('/app/wxPay/wxPayJsApiUserCertification', data).then(res => {
  647. console.log(res)
  648. if (res.code == 0) {
  649. // this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  650. uni.requestPayment({
  651. provider: 'wxpay',
  652. timeStamp: res.data.timestamp,
  653. nonceStr: res.data.noncestr,
  654. package: res.data.package,
  655. signType: res.data.signType,
  656. paySign: res.data.sign,
  657. success: function(res) {
  658. console.log(res)
  659. uni.switchTab({
  660. url: '/pages/my/index'
  661. })
  662. },
  663. fail: function(err) {
  664. this.$queue.showToast('支付失败');
  665. }
  666. });
  667. }
  668. });
  669. // #endif
  670. // #ifdef H5
  671. this.$Request.postJson('/app/wxPay/wxPayMpUserCertification', data).then(res => {
  672. this.showpay = false
  673. that.callPay(res);
  674. });
  675. // #endif
  676. // #ifdef APP
  677. this.$Request.postJson('/app/wxPay/payAppUserCertification', data).then(res => {
  678. console.log(res)
  679. this.showpay = false
  680. if (res.code == 0) {
  681. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  682. }
  683. });
  684. // #endif
  685. } else if (this.openWay == 2) { //支付宝支付
  686. // #ifdef H5
  687. this.$Request.postJson('/app/aliPay/payOrderUserCertification', data).then(
  688. res => {
  689. this.showpay = false
  690. const div = document.createElement('div')
  691. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  692. document.body.appendChild(div)
  693. document.forms[0].submit()
  694. });
  695. // #endif
  696. // #ifdef APP-PLUS
  697. this.$Request.postJson('/app/aliPay/payAppUserCertification', data).then(
  698. res => {
  699. this.showpay = false
  700. this.setPayment('alipay', res.data);
  701. });
  702. // #endif
  703. }
  704. },
  705. callPay: function(response) {
  706. if (typeof WeixinJSBridge === "undefined") {
  707. if (document.addEventListener) {
  708. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  709. } else if (document.attachEvent) {
  710. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  711. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  712. }
  713. } else {
  714. this.onBridgeReady(response);
  715. }
  716. },
  717. onBridgeReady: function(response) {
  718. let that = this;
  719. if (!response.package) {
  720. return;
  721. }
  722. WeixinJSBridge.invoke(
  723. 'getBrandWCPayRequest', {
  724. "appId": response.appid, //公众号名称,由商户传入
  725. "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
  726. "nonceStr": response.noncestr, //随机串
  727. "package": response.package,
  728. "signType": response.signType, //微信签名方式:
  729. "paySign": response.sign //微信签名
  730. },
  731. function(res) {
  732. if (res.err_msg === "get_brand_wcpay_request:ok") {
  733. // 使用以上方式判断前端返回,微信团队郑重提示:
  734. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  735. uni.showLoading({
  736. title: '支付成功'
  737. });
  738. uni.hideLoading();
  739. uni.navigateTo({
  740. url: '/pages/my/index'
  741. })
  742. } else {
  743. uni.hideLoading();
  744. }
  745. WeixinJSBridge.log(response.err_msg);
  746. }
  747. );
  748. },
  749. isCheckPay(code, name, order) {
  750. if (code == 0) {
  751. this.setPayment(name, order);
  752. } else {
  753. uni.hideLoading();
  754. uni.showToast({
  755. title: '支付信息有误'
  756. });
  757. }
  758. },
  759. setPayment(name, order) {
  760. uni.requestPayment({
  761. provider: name,
  762. orderInfo: order, //微信、支付宝订单数据
  763. success: function(res) {
  764. uni.hideLoading();
  765. uni.showLoading({
  766. title: '支付成功'
  767. });
  768. uni.switchTab({
  769. url: '/pages/my/index'
  770. })
  771. },
  772. fail: function(err) {
  773. uni.hideLoading();
  774. },
  775. complete() {
  776. uni.hideLoading();
  777. }
  778. });
  779. }
  780. }
  781. }
  782. </script>
  783. <style>
  784. page {
  785. background-color: #F5F5F5;
  786. }
  787. .bg {
  788. background-color: #FFFFFF;
  789. }
  790. .tabBox {
  791. border: 1rpx solid #999999;
  792. padding: 15rpx 20rpx;
  793. border-radius: 15rpx;
  794. font-size: 28rpx;
  795. }
  796. .btnnum {
  797. color: #2FB57A;
  798. border: 1rpx solid #2FB57A;
  799. }
  800. .tabbar {
  801. width: 100%;
  802. height: 98upx;
  803. background: #FFFFFF;
  804. display: flex;
  805. justify-content: space-between;
  806. align-items: center;
  807. position: fixed;
  808. bottom: 0;
  809. left: 0;
  810. right: 0;
  811. padding: 0upx 40upx;
  812. }
  813. .popup_pay {
  814. width: 100%;
  815. position: relative;
  816. padding-bottom: 45rpx;
  817. /* height: 160px; */
  818. /* #ifndef MP-WEIXIN */
  819. /* height: 130px; */
  820. /* #endif */
  821. }
  822. .pay_btn {
  823. width: 90%;
  824. margin: 0 auto;
  825. text-align: center;
  826. background: #1777FF;
  827. height: 80rpx;
  828. border-radius: 16rpx;
  829. color: #ffffff;
  830. line-height: 80rpx;
  831. }
  832. </style>