payment.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  1. <template>
  2. <u-popup :show="payshow" @close="payclose" @open="payopen" round="12" :closeable="true">
  3. <view :class="[AppTheme]" class="app">
  4. <view class="price-box">
  5. <text>支付金额</text>
  6. <text class="price text-neutral">{{params.money}}</text>
  7. </view>
  8. <view class="pay-type-list">
  9. <radio-group>
  10. <view v-if="weixinpay2" class="type-item b-b" @click="changepaytype(1)">
  11. <u-icon name="weixin-fill" color="#62b900" size="30"></u-icon>
  12. <view class="con">
  13. <text class="tit">微信支付</text>
  14. <text style="padding-top: 10rpx;">推荐使用微信支付</text>
  15. </view>
  16. <label class="radio">
  17. <radio value="1" :color="primary" :checked='params.paytype == 1' />
  18. </radio>
  19. </label>
  20. </view>
  21. <!-- #ifdef APP-PLUS || H5 -->
  22. <view v-if="alipay2" class="type-item" @click="changepaytype(3)">
  23. <u-icon name="zhifubao" color="rgb(85, 170, 255)" size="30"></u-icon>
  24. <view class="con">
  25. <text class="tit">支付宝支付</text>
  26. </view>
  27. <label class="radio">
  28. <radio value="3" :color="primary" :checked='params.paytype == 3' />
  29. </radio>
  30. </label>
  31. </view>
  32. <!-- #endif -->
  33. <view v-if="zhtpay" class="type-item" @click="changepaytype(2)">
  34. <u-icon name="red-packet-fill" color="rgb(224, 116, 114)" size="30"></u-icon>
  35. <view class="con">
  36. <text class="tit">余额支付</text>
  37. <text style="padding-top: 10rpx;">可用余额 ¥{{balance}}</text>
  38. </view>
  39. <label class="radio">
  40. <radio value="2" :color="primary" :checked='params.paytype == 2' />
  41. </radio>
  42. </label>
  43. </view>
  44. </radio-group>
  45. </view>
  46. <text class="mix-btn bg-linear-gradient" @click="confirm">确认支付</text>
  47. <u-keyboard ref="uKeyboard" mode="number" :tooltip="false" :safeAreaInsetBottom="true" :overlay="true"
  48. :closeOnClickOverlay="true" :dotDisabled="false" @change="onChange" @backspace="onBackspace"
  49. :show="show">
  50. <view>
  51. <view class="u-text-center u-padding-20 money">
  52. <view class="text-neutral">
  53. <text>{{params.money}}</text>
  54. <text class="u-font-20 u-padding-left-10">元</text>
  55. </view>
  56. <view class="u-padding-10 close" data-flag="false" @tap="showPop(false)">
  57. <u-icon name="close" color="#333333" size="28"></u-icon>
  58. </view>
  59. </view>
  60. <view class="u-flex u-row-center codeinput" style="margin: 20rpx 0; padding: auto;100%;">
  61. <u-code-input :color="primary" :borderColor="primary" :space="20" size="40" mode="box"
  62. :maxlength="6" :dot="true" v-model="password" :disabledKeyboard="true" @finish="finish">
  63. </u-code-input>
  64. </view>
  65. </view>
  66. </u-keyboard>
  67. </view>
  68. </u-popup>
  69. </template>
  70. <script>
  71. // #ifdef H5
  72. var wx = require('jweixin-module');
  73. // #endif
  74. import wallApi from '@/api/wall/index.js';
  75. import cart from '@/api/cart/index.js';
  76. import api from '@/api/mall/index.js';
  77. import adoptApi from '@/api/home/index.js';
  78. import {
  79. allKeys
  80. } from '../../js/underscore';
  81. export default {
  82. name: "payment",
  83. props: ["channel", "weixinpay", "alipay", "zhtpay"], //1:(商品,砍价 ,拼团),2:认养,,3:充值,4:租地,5:活动,6:保证金
  84. data() {
  85. return {
  86. primary: this.$theme.primary,
  87. settingFile: getApp().globalData.siteinfo,
  88. payshow: false,
  89. show: false,
  90. password: '',
  91. balance: 0,
  92. params: {
  93. // 支付方式
  94. paytype: 1, //1:微信,2:余额,3:支付宝
  95. systype: '', //h5 或 app 或 mpweixin
  96. money: 0
  97. },
  98. weixinpay2: true,
  99. alipay2: false,
  100. };
  101. },
  102. created() {
  103. let that = this;
  104. wallApi.income({}).then(res => {
  105. if (res.status == 200) {
  106. that.balance = res.data.money; //余额
  107. }
  108. });
  109. let config = that.$init_config(1, function(res) {
  110. console.log(res,'res');
  111. if (res && res.app) {
  112. // that.weixinpay2 = res.app.pay.wx.isopen;
  113. // that.alipay2 = res.app.pay.ali.isopen;
  114. }
  115. });
  116. },
  117. methods: {
  118. init(data) {
  119. let that = this;
  120. if (data) {
  121. that.params = data;
  122. that.params.money = parseFloat(that.params.money).toFixed(2);
  123. // #ifdef APP-PLUS
  124. that.params.systype = 'app'
  125. // #endif
  126. // #ifdef H5
  127. that.params.systype = 'h5'
  128. // #endif
  129. // #ifdef MP-WEIXIN
  130. that.params.systype = 'mpweixin'
  131. // #endif
  132. }
  133. },
  134. payopen(data) {
  135. let that = this;
  136. that.init(data);
  137. that.payshow = true;
  138. },
  139. payclose() {
  140. let that = this;
  141. that.payshow = false;
  142. },
  143. changepaytype(type) {
  144. let that = this;
  145. that.params.paytype = type;
  146. },
  147. confirm() {
  148. let that = this;
  149. if (that.params.paytype == 1) {
  150. that.paywx();
  151. } else if (that.params.paytype == 2) {
  152. if (that.channel != 3) {
  153. that.show = true;
  154. that.password = ''
  155. } else {
  156. uni.showToast({
  157. title: '请选择正确的支付方式',
  158. icon: 'none'
  159. })
  160. return;
  161. }
  162. } else if (that.params.paytype == 3) {
  163. that.payali();
  164. } else {
  165. uni.showToast({
  166. title: '请选择正确的支付方式',
  167. icon: 'none'
  168. })
  169. return;
  170. }
  171. },
  172. onChange(val) {
  173. let that = this;
  174. if (that.password.length < 6) {
  175. that.password += val;
  176. }
  177. if (that.password.length >= 6) {
  178. if (that.params.paytype == 1) {
  179. that.paywx();
  180. } else if (that.params.paytype == 2) {
  181. that.paybalance();
  182. }
  183. }
  184. },
  185. onBackspace(e) {
  186. let that = this;
  187. if (that.password.length > 0) {
  188. that.password = that.password.substring(0, that.password.length - 1);
  189. }
  190. },
  191. paywx() {
  192. let that = this;
  193. console.log(this.channel,'channel',that.params);
  194. if (that.channel == 1) {
  195. that.$paycenter.paygood(that.params).then(res => {
  196. console.log(res,'支付回调');
  197. if (res.status === 0 || res.code === 0) {
  198. uni.showToast({
  199. title: res.msg,
  200. icon: 'none'
  201. })
  202. } else {
  203. // #ifdef APP-PLUS
  204. that.wxPayAPPPLUS(res.data)
  205. // #endif
  206. // #ifdef H5
  207. that.wxPayH5(res.data)
  208. // #endif
  209. // #ifdef MP-WEIXIN
  210. that.wxPayWEIXIN(res.data)
  211. // #endif
  212. }
  213. })
  214. } else if (that.channel == 2) {
  215. that.$paycenter.payrenyang(that.params).then(res => {
  216. if (res.status === 0 || res.code === 0) {
  217. uni.showToast({
  218. title: res.msg,
  219. icon: 'none'
  220. })
  221. } else {
  222. // #ifdef APP-PLUS
  223. that.wxPayAPPPLUS(res.data)
  224. // #endif
  225. // #ifdef H5
  226. that.wxPayH5(res.data)
  227. // #endif
  228. // #ifdef MP-WEIXIN
  229. that.wxPayWEIXIN(res.data)
  230. // #endif
  231. }
  232. })
  233. } else if (that.channel == 3) {
  234. that.$paycenter.paycz(that.params).then(res => {
  235. if (res.status === 0 || res.code === 0) {
  236. uni.showToast({
  237. title: res.msg,
  238. icon: 'none'
  239. })
  240. } else {
  241. // #ifdef APP-PLUS
  242. that.wxPayAPPPLUS(res.data)
  243. // #endif
  244. // #ifdef H5
  245. that.wxPayH5(res.data)
  246. // #endif
  247. // #ifdef MP-WEIXIN
  248. that.wxPayWEIXIN(res.data)
  249. // #endif
  250. }
  251. })
  252. } else if (that.channel == 4) {
  253. that.$paycenter.payland(that.params).then(res => {
  254. if (res.status === 0 || res.code === 0) {
  255. uni.showToast({
  256. title: res.msg,
  257. icon: 'none'
  258. })
  259. } else {
  260. // #ifdef APP-PLUS
  261. that.wxPayAPPPLUS(res.data)
  262. // #endif
  263. // #ifdef H5
  264. that.wxPayH5(res.data)
  265. // #endif
  266. // #ifdef MP-WEIXIN
  267. that.wxPayWEIXIN(res.data)
  268. // #endif
  269. }
  270. })
  271. } else if (that.channel == 5) {
  272. that.$paycenter.payactivity(that.params).then(res => {
  273. if (res.status === 0 || res.code === 0) {
  274. uni.showToast({
  275. title: res.msg,
  276. icon: 'none'
  277. })
  278. } else {
  279. // #ifdef APP-PLUS
  280. that.wxPayAPPPLUS(res.data)
  281. // #endif
  282. // #ifdef H5
  283. that.wxPayH5(res.data)
  284. // #endif
  285. // #ifdef MP-WEIXIN
  286. that.wxPayWEIXIN(res.data)
  287. // #endif
  288. }
  289. })
  290. } else if (that.channel == 6) {
  291. that.$paycenter.renewal(that.params).then(res => {
  292. if (res.status === 0 || res.code === 0) {
  293. uni.showToast({
  294. title: res.msg,
  295. icon: 'none'
  296. })
  297. } else {
  298. // #ifdef APP-PLUS
  299. that.wxPayAPPPLUS(res.data)
  300. // #endif
  301. // #ifdef H5
  302. that.wxPayH5(res.data)
  303. // #endif
  304. // #ifdef MP-WEIXIN
  305. that.wxPayWEIXIN(res.data)
  306. // #endif
  307. }
  308. })
  309. } else if (that.channel == 7) {
  310. that.$paycenter.seedpay(that.params).then(res => {
  311. if (res.status === 0 || res.code === 0) {
  312. uni.showToast({
  313. title: res.msg,
  314. icon: 'none'
  315. })
  316. } else {
  317. // #ifdef APP-PLUS
  318. that.wxPayAPPPLUS(res.data)
  319. // #endif
  320. // #ifdef H5
  321. that.wxPayH5(res.data)
  322. // #endif
  323. // #ifdef MP-WEIXIN
  324. that.wxPayWEIXIN(res.data)
  325. // #endif
  326. }
  327. })
  328. } else if (that.channel == 8) {
  329. that.$paycenter.payserve(that.params).then(res => {
  330. if (res.status === 0 || res.code === 0) {
  331. uni.showToast({
  332. title: res.msg,
  333. icon: 'none'
  334. })
  335. } else {
  336. // #ifdef APP-PLUS
  337. that.wxPayAPPPLUS(res.data)
  338. // #endif
  339. // #ifdef H5
  340. that.wxPayH5(res.data)
  341. // #endif
  342. // #ifdef MP-WEIXIN
  343. that.wxPayWEIXIN(res.data)
  344. // #endif
  345. }
  346. })
  347. } else if (that.channel == 9) {
  348. that.$paycenter.operator(that.params).then(res => {
  349. if (res.status === 0 || res.code === 0) {
  350. uni.showToast({
  351. title: res.msg,
  352. icon: 'none'
  353. })
  354. } else {
  355. // #ifdef APP-PLUS
  356. that.wxPayAPPPLUS(res.data)
  357. // #endif
  358. // #ifdef H5
  359. that.wxPayH5(res.data)
  360. // #endif
  361. // #ifdef MP-WEIXIN
  362. that.wxPayWEIXIN(res.data)
  363. // #endif
  364. }
  365. })
  366. } else if (that.channel == 10) {
  367. that.$paycenter.paybond(that.params).then(res => {
  368. if (res.status === 0 || res.code === 0) {
  369. uni.showToast({
  370. title: res.msg,
  371. icon: 'none'
  372. })
  373. } else {
  374. // #ifdef APP-PLUS
  375. that.wxPayAPPPLUS(res.data)
  376. // #endif
  377. // #ifdef H5
  378. that.wxPayH5(res.data)
  379. // #endif
  380. // #ifdef MP-WEIXIN
  381. that.wxPayWEIXIN(res.data)
  382. // #endif
  383. }
  384. })
  385. }
  386. },
  387. payali() {
  388. let that = this;
  389. if (that.channel == 1) {
  390. that.$paycenter.paygood(that.params).then(res => {
  391. if (res.status === 0 || res.code === 0) {
  392. uni.showToast({
  393. title: res.msg,
  394. icon: 'none'
  395. })
  396. } else {
  397. // #ifdef APP-PLUS
  398. that.aliPayAPPPLUS(res.data)
  399. // #endif
  400. // #ifdef H5
  401. that.aliPayH5(res.data)
  402. // #endif
  403. }
  404. })
  405. } else if (that.channel == 2) {
  406. that.$paycenter.payrenyang(that.params).then(res => {
  407. if (res.status === 0 || res.code === 0) {
  408. uni.showToast({
  409. title: res.msg,
  410. icon: 'none'
  411. })
  412. } else {
  413. // #ifdef APP-PLUS
  414. that.aliPayAPPPLUS(res.data)
  415. // #endif
  416. // #ifdef H5
  417. that.aliPayH5(res.data)
  418. // #endif
  419. }
  420. })
  421. } else if (that.channel == 3) {
  422. that.$paycenter.paycz(that.params).then(res => {
  423. if (res.status === 0 || res.code === 0) {
  424. uni.showToast({
  425. title: res.msg,
  426. icon: 'none'
  427. })
  428. } else {
  429. // #ifdef APP-PLUS
  430. that.aliPayAPPPLUS(res.data)
  431. // #endif
  432. // #ifdef H5
  433. that.aliPayH5(res.data)
  434. // #endif
  435. }
  436. })
  437. } else if (that.channel == 4) {
  438. that.$paycenter.payland(that.params).then(res => {
  439. if (res.status === 0 || res.code === 0) {
  440. uni.showToast({
  441. title: res.msg,
  442. icon: 'none'
  443. })
  444. } else {
  445. // #ifdef APP-PLUS
  446. that.aliPayAPPPLUS(res.data)
  447. // #endif
  448. // #ifdef H5
  449. that.aliPayH5(res.data)
  450. // #endif
  451. }
  452. })
  453. } else if (that.channel == 5) {
  454. that.$paycenter.payactivity(that.params).then(res => {
  455. if (res.status === 0 || res.code === 0) {
  456. uni.showToast({
  457. title: res.msg,
  458. icon: 'none'
  459. })
  460. } else {
  461. // #ifdef APP-PLUS
  462. that.aliPayAPPPLUS(res.data)
  463. // #endif
  464. // #ifdef H5
  465. that.aliPayH5(res.data)
  466. // #endif
  467. }
  468. })
  469. } else if (that.channel == 6) {
  470. that.$paycenter.renewal(that.params).then(res => {
  471. if (res.status === 0 || res.code === 0) {
  472. uni.showToast({
  473. title: res.msg,
  474. icon: 'none'
  475. })
  476. } else {
  477. // #ifdef APP-PLUS
  478. that.aliPayAPPPLUS(res.data)
  479. // #endif
  480. // #ifdef H5
  481. that.aliPayH5(res.data)
  482. // #endif
  483. }
  484. })
  485. } else if (that.channel == 7) {
  486. that.$paycenter.seedpay(that.params).then(res => {
  487. if (res.status === 0 || res.code === 0) {
  488. uni.showToast({
  489. title: res.msg,
  490. icon: 'none'
  491. })
  492. } else {
  493. // #ifdef APP-PLUS
  494. that.aliPayAPPPLUS(res.data)
  495. // #endif
  496. // #ifdef H5
  497. that.aliPayH5(res.data)
  498. // #endif
  499. }
  500. })
  501. } else if (that.channel == 8) {
  502. that.$paycenter.payserve(that.params).then(res => {
  503. if (res.status === 0 || res.code === 0) {
  504. uni.showToast({
  505. title: res.msg,
  506. icon: 'none'
  507. })
  508. } else {
  509. // #ifdef APP-PLUS
  510. that.aliPayAPPPLUS(res.data)
  511. // #endif
  512. // #ifdef H5
  513. that.aliPayH5(res.data)
  514. // #endif
  515. }
  516. })
  517. } else if (that.channel == 9) {
  518. that.$paycenter.operator(that.params).then(res => {
  519. if (res.status === 0 || res.code === 0) {
  520. uni.showToast({
  521. title: res.msg,
  522. icon: 'none'
  523. })
  524. } else {
  525. // #ifdef APP-PLUS
  526. that.aliPayAPPPLUS(res.data)
  527. // #endif
  528. // #ifdef H5
  529. that.aliPayH5(res.data)
  530. // #endif
  531. }
  532. })
  533. } else if (that.channel == 10) {
  534. that.$paycenter.paybond(that.params).then(res => {
  535. if (res.status === 0 || res.code === 0) {
  536. uni.showToast({
  537. title: res.msg,
  538. icon: 'none'
  539. })
  540. } else {
  541. // #ifdef APP-PLUS
  542. that.aliPayAPPPLUS(res.data)
  543. // #endif
  544. // #ifdef H5
  545. that.aliPayH5(res.data)
  546. // #endif
  547. }
  548. })
  549. }
  550. },
  551. paybalance() {
  552. let that = this;
  553. if (that.channel == 1) {
  554. that.paybalance1()
  555. } else if (that.channel == 2) {
  556. that.paybalance2()
  557. } else if (that.channel == 4) {
  558. that.paybalance4()
  559. } else if (that.channel == 5) {
  560. that.paybalance5()
  561. } else if (that.channel == 6) {
  562. that.paybalance6()
  563. } else if (that.channel == 7) {
  564. that.paybalance7()
  565. } else if (that.channel == 8) {
  566. that.paybalance8()
  567. } else if (that.channel == 9) {
  568. that.paybalance9()
  569. } else if (that.channel == 10) {
  570. that.paybalance10()
  571. }
  572. },
  573. wxPayWEIXIN(paydata) {
  574. let that = this;
  575. uni.requestPayment({
  576. provider: 'wxpay',
  577. timeStamp: paydata.timeStamp,
  578. nonceStr: paydata.nonceStr,
  579. package: paydata.package,
  580. signType: paydata.signType,
  581. paySign: paydata.paySign,
  582. success: function(res) {
  583. uni.showToast({
  584. title: '支付成功',
  585. icon: 'success',
  586. duration: 1500
  587. });
  588. that.payfinish()
  589. },
  590. fail: function(err) {
  591. console.log('err', err)
  592. }
  593. });
  594. },
  595. wxPayH5(paydata) {
  596. let that = this;
  597. console.log(paydata,'paydata.appid');
  598. wx.config({
  599. debug: false,
  600. appId: paydata.appId, // 必填,公众号的唯一标识
  601. timestamp: paydata.timeStamp, // 必填,生成签名的时间戳
  602. nonceStr: paydata.nonceStr, // 必填,生成签名的随机串
  603. signature: paydata.paySign,
  604. jsApiList: ['chooseWXPay']
  605. });
  606. wx.ready(function() {
  607. wx.chooseWXPay({
  608. timestamp: paydata.timeStamp,
  609. nonceStr: paydata.nonceStr, // 支付签名随机串,不长于 32 位
  610. package: paydata.package,
  611. signType: 'MD5', // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
  612. paySign: paydata.paySign, // 支付签名
  613. success(res) {
  614. that.payfinish()
  615. },
  616. fail(err) {
  617. console.log('fail', err)
  618. uni.showToast({
  619. icon: 'none',
  620. title: '未完成支付!'
  621. })
  622. }
  623. });
  624. });
  625. },
  626. wxPayAPPPLUS(paydata) {
  627. let that = this;
  628. console.log('paydata',paydata)
  629. uni.requestPayment({
  630. provider: 'wxpay',
  631. orderInfo: paydata,
  632. success: function(res) {
  633. uni.showToast({
  634. title: '支付成功',
  635. icon: 'success',
  636. duration: 1500
  637. });
  638. that.payfinish()
  639. },
  640. fail: function(err) {
  641. console.log('fail', err)
  642. uni.showToast({
  643. title: err.errMsg,
  644. icon: 'none'
  645. })
  646. }
  647. });
  648. },
  649. aliPayH5(paydata) {
  650. let that = this;
  651. uni.showToast({
  652. icon: 'none',
  653. title: '暂未开放!'
  654. })
  655. wx.config({
  656. debug: false,
  657. appId: paydata.appid, // 必填,公众号的唯一标识
  658. timestamp: paydata.timeStamp, // 必填,生成签名的时间戳
  659. nonceStr: paydata.nonceStr, // 必填,生成签名的随机串
  660. signature: paydata.paySign,
  661. jsApiList: ['chooseWXPay']
  662. });
  663. wx.ready(function() {
  664. wx.chooseWXPay({
  665. timestamp: paydata.timeStamp,
  666. nonceStr: paydata.nonceStr, // 支付签名随机串,不长于 32 位
  667. package: paydata.package,
  668. signType: 'MD5', // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
  669. paySign: paydata.paySign, // 支付签名
  670. success(res) {
  671. that.payfinish()
  672. },
  673. fail(err) {
  674. console.log('fail', err)
  675. uni.showToast({
  676. icon: 'none',
  677. title: '未完成支付!'
  678. })
  679. }
  680. });
  681. });
  682. },
  683. aliPayAPPPLUS(paydata) {
  684. let that = this;
  685. console.log('paydata', paydata)
  686. uni.requestPayment({
  687. provider: 'alipay',
  688. orderInfo: paydata,
  689. success: function(res) {
  690. uni.showToast({
  691. title: '支付成功',
  692. icon: 'success',
  693. duration: 1500
  694. });
  695. that.payfinish()
  696. },
  697. fail: function(err) {
  698. console.log('fail', err)
  699. uni.showToast({
  700. title: err.errMsg,
  701. icon: 'none'
  702. })
  703. }
  704. });
  705. },
  706. //余额支付
  707. paybalance1() {
  708. let that = this;
  709. cart.checkPayPassword({
  710. password: that.password
  711. }).then(res => {
  712. uni.hideLoading();
  713. if (res.status == 200) {
  714. var pdata = {
  715. orderid: that.params.orderid,
  716. djqid: that.params.djqid,
  717. type: that.params.paytype == 1 ? 'wxpay' : 'money',
  718. paypass: that.password
  719. };
  720. api.pay(pdata)
  721. .then(res => {
  722. uni.showToast({
  723. title: res.msg,
  724. icon: "none"
  725. });
  726. if (res.status == 200) {
  727. that.payfinish()
  728. }
  729. });
  730. } else {
  731. uni.showToast({
  732. title: res.msg,
  733. icon: "none"
  734. });
  735. if (res.msg === '未设置支付密码,现在进行设置!') {
  736. setTimeout(() => {
  737. uni.navigateTo({
  738. url: '/pagesD/pages/set/changemima/changemima'
  739. })
  740. }, 1000)
  741. }
  742. }
  743. })
  744. },
  745. //余额支付
  746. paybalance2() {
  747. let that = this;
  748. cart.checkPayPassword({
  749. password: that.password
  750. }).then(res => {
  751. uni.hideLoading();
  752. if (res.status == 200) {
  753. var pdata = {
  754. orderid: that.params.orderid,
  755. djqid: that.params.djqid,
  756. type: that.params.paytype == 1 ? 'wxpay' : 'money',
  757. paypass: that.password
  758. };
  759. adoptApi.payNew(pdata)
  760. .then(res => {
  761. uni.showToast({
  762. title: res.msg,
  763. icon: "none"
  764. });
  765. if (res.status == 200) {
  766. that.payfinish()
  767. }
  768. });
  769. } else {
  770. uni.showToast({
  771. title: res.msg,
  772. icon: "none"
  773. });
  774. if (res.msg === '未设置支付密码,现在进行设置!') {
  775. setTimeout(() => {
  776. uni.navigateTo({
  777. url: '/pagesD/pages/set/changemima/changemima'
  778. })
  779. }, 1000)
  780. }
  781. }
  782. })
  783. },
  784. //余额支付
  785. paybalance4() {
  786. let that = this;
  787. cart.checkPayPassword({
  788. password: that.password
  789. }).then(res => {
  790. uni.hideLoading();
  791. if (res.status == 200) {
  792. let pdata = {
  793. order_info: JSON.stringify(that.params)
  794. };
  795. that.$paycenter.pay_soil_money(pdata)
  796. .then(res => {
  797. uni.showToast({
  798. title: res.msg,
  799. icon: "none"
  800. });
  801. if (res.status == 200) {
  802. that.payfinish()
  803. }
  804. });
  805. } else {
  806. uni.showToast({
  807. title: res.msg,
  808. icon: "none"
  809. });
  810. if (res.msg === '未设置支付密码,现在进行设置!') {
  811. setTimeout(() => {
  812. uni.navigateTo({
  813. url: '/pagesD/pages/set/changemima/changemima'
  814. })
  815. }, 1000)
  816. }
  817. }
  818. })
  819. },
  820. //余额支付
  821. paybalance5() {
  822. let that = this;
  823. cart.checkPayPassword({
  824. password: that.password
  825. }).then(res => {
  826. uni.hideLoading();
  827. if (res.status == 200) {
  828. that.$paycenter.pay_ac_money(that.params)
  829. .then(res => {
  830. uni.showToast({
  831. title: res.msg,
  832. icon: "none"
  833. });
  834. if (res.status == 200) {
  835. that.payfinish()
  836. }
  837. });
  838. } else {
  839. uni.showToast({
  840. title: res.msg,
  841. icon: "none"
  842. });
  843. if (res.msg === '未设置支付密码,现在进行设置!') {
  844. setTimeout(() => {
  845. uni.navigateTo({
  846. url: '/pagesD/pages/set/changemima/changemima'
  847. })
  848. }, 1000)
  849. }
  850. }
  851. })
  852. },
  853. //余额支付
  854. paybalance6() {
  855. let that = this;
  856. cart.checkPayPassword({
  857. password: that.password
  858. }).then(res => {
  859. uni.hideLoading();
  860. if (res.status == 200) {
  861. that.$paycenter.pay_renewal_money(that.params)
  862. .then(res => {
  863. uni.showToast({
  864. title: res.msg,
  865. icon: "none"
  866. });
  867. if (res.status == 200) {
  868. uni.showToast({
  869. title: res.msg,
  870. icon: "none"
  871. });
  872. setTimeout(() => {
  873. uni.navigateTo({
  874. url: '/pagesE/pages/plotdetails/plotdetails?orderid=' +
  875. that.params.orderid
  876. })
  877. }, 2000)
  878. }
  879. });
  880. } else {
  881. uni.showToast({
  882. title: res.msg,
  883. icon: "none"
  884. });
  885. if (res.msg === '未设置支付密码,现在进行设置!') {
  886. setTimeout(() => {
  887. uni.navigateTo({
  888. url: '/pagesD/pages/set/changemima/changemima'
  889. })
  890. }, 1000)
  891. }
  892. }
  893. })
  894. },
  895. //余额支付
  896. paybalance7() {
  897. let that = this;
  898. cart.checkPayPassword({
  899. password: that.password
  900. }).then(res => {
  901. uni.hideLoading();
  902. if (res.status == 200) {
  903. that.$paycenter.pay_seed_money(that.params)
  904. .then(res => {
  905. uni.showToast({
  906. title: res.msg,
  907. icon: "none"
  908. });
  909. if (res.status == 200) {
  910. uni.showToast({
  911. title: res.msg,
  912. icon: "none"
  913. });
  914. setTimeout(() => {
  915. uni.navigateTo({
  916. url: '/pagesE/pages/plotdetails/plotdetails?orderid=' +
  917. that.params.orderid
  918. })
  919. }, 2000)
  920. }
  921. });
  922. } else {
  923. uni.showToast({
  924. title: res.msg,
  925. icon: "none"
  926. });
  927. if (res.msg === '未设置支付密码,现在进行设置!') {
  928. setTimeout(() => {
  929. uni.navigateTo({
  930. url: '/pagesD/pages/set/changemima/changemima'
  931. })
  932. }, 1000)
  933. }
  934. }
  935. })
  936. },
  937. //余额支付
  938. paybalance8() {
  939. let that = this;
  940. cart.checkPayPassword({
  941. password: that.password
  942. }).then(res => {
  943. uni.hideLoading();
  944. if (res.status == 200) {
  945. that.$paycenter.pay_serve_money(that.params)
  946. .then(res => {
  947. uni.showToast({
  948. title: res.msg,
  949. icon: "none"
  950. });
  951. if (res.status == 200) {
  952. uni.showToast({
  953. title: res.msg,
  954. icon: "none"
  955. });
  956. setTimeout(() => {
  957. uni.navigateTo({
  958. url: '/pagesE/pages/plotdetails/plotdetails?orderid=' +
  959. that.params.orderid
  960. })
  961. }, 2000)
  962. }
  963. });
  964. } else {
  965. uni.showToast({
  966. title: res.msg,
  967. icon: "none"
  968. });
  969. if (res.msg === '未设置支付密码,现在进行设置!') {
  970. setTimeout(() => {
  971. uni.navigateTo({
  972. url: '/pagesD/pages/set/changemima/changemima'
  973. })
  974. }, 1000)
  975. }
  976. }
  977. })
  978. },
  979. //余额支付
  980. paybalance9() {
  981. let that = this;
  982. cart.checkPayPassword({
  983. password: that.password
  984. }).then(res => {
  985. uni.hideLoading();
  986. if (res.status == 200) {
  987. that.$paycenter.pay_operator_money(that.params)
  988. .then(res => {
  989. uni.showToast({
  990. title: res.msg,
  991. icon: "none"
  992. });
  993. if (res.status == 200) {
  994. uni.showToast({
  995. title: res.msg,
  996. icon: "none"
  997. });
  998. console.log(that.params.type, 'that.params.type')
  999. if (that.params.type == 2) {
  1000. setTimeout(() => {
  1001. uni.navigateTo({
  1002. url: '/pagesE/pages/seedlist/decoration/decoration?id=' +
  1003. that.params.order_id
  1004. })
  1005. }, 2000)
  1006. } else {
  1007. setTimeout(() => {
  1008. uni.navigateTo({
  1009. url: '/pagesE/pages/seedlist/crop?id=' + that
  1010. .params.seed_id
  1011. })
  1012. }, 2000)
  1013. }
  1014. }
  1015. });
  1016. } else {
  1017. uni.showToast({
  1018. title: res.msg,
  1019. icon: "none"
  1020. });
  1021. if (res.msg === '未设置支付密码,现在进行设置!') {
  1022. setTimeout(() => {
  1023. uni.navigateTo({
  1024. url: '/pagesD/pages/set/changemima/changemima'
  1025. })
  1026. }, 1000)
  1027. }
  1028. }
  1029. })
  1030. },
  1031. //余额支付
  1032. paybalance10() {
  1033. let that = this;
  1034. cart.checkPayPassword({
  1035. password: that.password
  1036. }).then(res => {
  1037. uni.hideLoading();
  1038. if (res.status == 200) {
  1039. that.$paycenter.pay_bond_money(that.params)
  1040. .then(res => {
  1041. uni.showToast({
  1042. title: res.msg,
  1043. icon: "none"
  1044. });
  1045. if (res.status == 200) {
  1046. uni.showToast({
  1047. title: res.msg,
  1048. icon: "none"
  1049. });
  1050. setTimeout(() => {
  1051. uni.navigateTo({
  1052. url: '/pagesC/pages/merchantdetails/bond'
  1053. })
  1054. }, 1000)
  1055. }
  1056. });
  1057. } else {
  1058. uni.showToast({
  1059. title: res.msg,
  1060. icon: "none"
  1061. });
  1062. if (res.msg === '未设置支付密码,现在进行设置!') {
  1063. setTimeout(() => {
  1064. uni.navigateTo({
  1065. url: '/pagesD/pages/set/changemima/changemima'
  1066. })
  1067. }, 1000)
  1068. }
  1069. }
  1070. })
  1071. },
  1072. showPop(flag = true) {
  1073. let that = this;
  1074. that.password = '';
  1075. that.show = flag;
  1076. },
  1077. finish() {
  1078. },
  1079. payfinish() {
  1080. let that = this;
  1081. if (that.channel == 3) {
  1082. that.payclose();
  1083. //1:(商品,砍价 ,拼团),2:认养,,3:充值,4:租地,5:活动
  1084. uni.navigateBack(-1);
  1085. } else if (that.channel == 10) {
  1086. that.payclose();
  1087. uni.navigateTo({
  1088. url: '/pagesC/pages/merchantdetails/bond'
  1089. });
  1090. } else {
  1091. setTimeout(function() {
  1092. //1:(商品,砍价 ,拼团),2:认养,,3:充值,4:租地,5:活动
  1093. uni.navigateTo({
  1094. url: '/pagesE/pages/common/paySuccess?channel=' + that.channel
  1095. });
  1096. }, 1000)
  1097. }
  1098. }
  1099. }
  1100. }
  1101. </script>
  1102. <style lang='scss'>
  1103. .codeinput {
  1104. justify-content: space-evenly;
  1105. display: flex;
  1106. }
  1107. .app {
  1108. width: 100%;
  1109. }
  1110. .money {
  1111. font-size: 80rpx;
  1112. position: relative;
  1113. text-align: center;
  1114. .close {
  1115. position: absolute;
  1116. top: 20rpx;
  1117. right: 20rpx;
  1118. line-height: 28rpx;
  1119. font-size: 28rpx;
  1120. }
  1121. }
  1122. .tips {
  1123. color: $u-tips-color;
  1124. text-align: center;
  1125. }
  1126. .price-box {
  1127. background-color: #fff;
  1128. height: 160rpx;
  1129. display: flex;
  1130. flex-direction: column;
  1131. justify-content: center;
  1132. align-items: center;
  1133. font-size: 28upx;
  1134. color: #909399;
  1135. .price {
  1136. font-size: 50upx;
  1137. margin-top: 12upx;
  1138. &:before {
  1139. content: '¥';
  1140. font-size: 40upx;
  1141. }
  1142. }
  1143. }
  1144. .pay-type-list {
  1145. /* margin-top: 20upx; */
  1146. background-color: #fff;
  1147. padding-left: 60upx;
  1148. .type-item {
  1149. height: 120upx;
  1150. display: flex;
  1151. justify-content: space-between;
  1152. align-items: center;
  1153. padding-right: 60upx;
  1154. font-size: 30upx;
  1155. position: relative;
  1156. .con {
  1157. margin-left: 20rpx;
  1158. }
  1159. }
  1160. .icon {
  1161. width: 100upx;
  1162. font-size: 52upx;
  1163. }
  1164. .icon-erjiye-yucunkuan {
  1165. color: #fe8e2e;
  1166. }
  1167. .icon-weixinzhifu {
  1168. color: #36cb59;
  1169. }
  1170. .icon-alipay {
  1171. color: #01aaef;
  1172. }
  1173. .tit {
  1174. font-size: $font-lg;
  1175. color: $font-color-dark;
  1176. margin-bottom: 4upx;
  1177. }
  1178. .con {
  1179. flex: 1;
  1180. display: flex;
  1181. flex-direction: column;
  1182. font-size: $font-sm;
  1183. color: $font-color-light;
  1184. }
  1185. }
  1186. .mix-btn {
  1187. display: flex;
  1188. align-items: center;
  1189. justify-content: center;
  1190. width: 630upx;
  1191. height: 80upx;
  1192. margin: 80upx auto 30upx;
  1193. font-size: $font-lg;
  1194. color: #fff;
  1195. border-radius: 10upx;
  1196. }
  1197. </style>