payment.vue 30 KB

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