You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

460 lines
9.1 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <view class="app-container" style="background-color: #ededed;">
  3. <view class="pam-content">
  4. <view class="pam-shop">
  5. <view class="pam-mess">
  6. <view class="picon">
  7. <img v-if="merchant.logo" :src="merchant.logo" style="width: 110rpx;height: 110rpx; border-radius: 50%;"
  8. alt="" srcset="" />
  9. <img v-else src="../../static/page/people.png" style="width: 110rpx;height: 110rpx;" alt="" srcset="" />
  10. </view>
  11. <view class="pam-address">
  12. <view class="pname">
  13. {{merchant.name}}
  14. </view>
  15. <view class="paddre">
  16. {{merchant.address || '未填写地址'}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="pam-local">
  21. <img src="../../static/page/location.png" style="width: 30rpx;height: 36rpx;" alt="" srcset="" />
  22. </view>
  23. </view>
  24. <view class="pam-main">
  25. <view class="pm-title">
  26. 付款金额()
  27. </view>
  28. <view class="pm-write">
  29. <view class="font">
  30. </view>
  31. <view class="num">
  32. <input type="text" class="pr-num" disabled v-model="amount" placeholder="请输入金额"
  33. placeholder-style="color: #cfcfcf;" />
  34. </view>
  35. </view>
  36. <view class="pfooter u-border-top">
  37. 向商家询问支付金额
  38. </view>
  39. </view>
  40. <view class="pac-cont">
  41. <view class="pac-left">
  42. <view class="pcfont">
  43. 支付金额给商户
  44. </view>
  45. <view class="pcline">
  46. </view>
  47. <view class="pc-aplay">
  48. 微信支付
  49. </view>
  50. </view>
  51. <view class="pac-link" @click="showDetail">
  52. 查看活动规则
  53. </view>
  54. </view>
  55. <u-overlay :show="showRule" :opacity="0.8" @click="showRule=false">
  56. <view class="warp">
  57. <image class="rect" :src="sysConfig.activity_rule_img" mode="aspectFit"></image>
  58. </view>
  59. </u-overlay>
  60. <!-- <u-keyboard confirmText="1" mode="number" :closeOnClickOverlay="true" @close="close" :show="show" @confirm="confirm" @cancel="cancel"></u-keyboard> -->
  61. <cu-keyboard ref="cukeyboard" @change="change" @confirm="confirm" @hide="hide" :safeHeight="safeHeight"></cu-keyboard>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import {
  67. userGetMerchantInfo,
  68. userCreateOrder,
  69. publicSysConfig
  70. } from '../../common/api.js'
  71. export default {
  72. data() {
  73. return {
  74. show: false,
  75. amount: '',
  76. payment_code: '',
  77. merchant: {
  78. name: '加载中...',
  79. address: '',
  80. logo: ''
  81. },
  82. safeHeight:0,
  83. sysConfig: {},
  84. showRule: false
  85. }
  86. },
  87. onReady() {
  88. this.$refs.cukeyboard.open();
  89. },
  90. onLoad() {
  91. this.payment_code = uni.getStorageSync('payment_code')
  92. this.getMerchantInfo()
  93. let info = uni.getSystemInfoSync()
  94. // alert(info.safeArea.bottom)
  95. // alert(info.screenHeight)
  96. // alert(info.safeArea.height)
  97. if(info.screenHeight!=info.safeArea.bottom){
  98. this.safeHeight = 20;
  99. }
  100. this.getSysConfig();
  101. },
  102. methods: {
  103. getSysConfig() {
  104. publicSysConfig().then(data => this.sysConfig = data)
  105. },
  106. getMerchantInfo() {
  107. userGetMerchantInfo({
  108. payment_code: this.payment_code
  109. }).then(data => this.merchant = data);
  110. },
  111. playFoucus() {
  112. if (this.show) {
  113. return
  114. }
  115. this.show = true;
  116. this.$refs.cukeyboard.open();
  117. },
  118. confirm() {
  119. //this.show = false;
  120. if (!this.checkMoney(this.amount)) {
  121. //alert("请输入正确金额");
  122. uni.showModal({
  123. content: "请输入正确金额",
  124. showCancel: false,
  125. confirmText: "知道了"
  126. })
  127. return
  128. }
  129. userCreateOrder({
  130. payment_code: this.payment_code,
  131. amount: this.amount
  132. }).then(data => {
  133. const onBridgeReady = function() {
  134. WeixinJSBridge.invoke(
  135. 'getBrandWCPayRequest', {
  136. appId: data.app_id, //公众号ID,由商户传入
  137. timeStamp: data.time_stamp, //时间戳,自1970年以来的秒数
  138. nonceStr: data.nonce_str, //随机串
  139. package: data.package,
  140. signType: data.sign_type, //微信签名方式:
  141. paySign: data.pay_sign //微信签名
  142. },
  143. function(res) {
  144. console.log(res)
  145. if (res.err_msg == "get_brand_wcpay_request:ok") {
  146. // 使用以上方式判断前端返回,微信团队郑重提示:
  147. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  148. }
  149. }
  150. );
  151. }
  152. if (typeof WeixinJSBridge == "undefined") {
  153. if (document.addEventListener) {
  154. document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
  155. } else if (document.attachEvent) {
  156. document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
  157. document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
  158. }
  159. } else {
  160. onBridgeReady();
  161. }
  162. });
  163. },
  164. cancel() {
  165. this.show = false;
  166. },
  167. close() {
  168. this.show = false;
  169. },
  170. change(v) {
  171. console.log("change :", v)
  172. this.amount = v
  173. },
  174. hide() {
  175. },
  176. checkMoney(val) {
  177. // 找到充值金额
  178. var rechargeMoney = val;
  179. var reg = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^0$)|(^\d\.\d{1,2}$)/;
  180. if (rechargeMoney == "") {
  181. return false;
  182. } else if (rechargeMoney.trim() == "") {
  183. return false;
  184. } else if (!reg.test(rechargeMoney)) {
  185. return false;
  186. } else if (rechargeMoney == 0) {
  187. return false;
  188. } else {
  189. return true;
  190. }
  191. },
  192. showDetail() {
  193. console.log("showDetail")
  194. this.showRule = true
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss">
  200. .uni-page-body {
  201. background: #ededed;
  202. }
  203. .warp {
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. height: 100vh;
  208. }
  209. .rect {
  210. width: 90vw !important;
  211. height: 90vh !important;
  212. }
  213. .pam-content {
  214. padding-top: 50rpx;
  215. padding-left: 30rpx;
  216. padding-right: 30rpx;
  217. .pam-shop {
  218. display: flex;
  219. justify-content: space-between;
  220. .pam-mess {
  221. display: flex;
  222. height: 110rpx;
  223. .picon {
  224. width: 110rpx;
  225. height: 110rpx;
  226. }
  227. .pam-address {
  228. margin-left: 20rpx;
  229. .pname {
  230. margin-top: 15rpx;
  231. color: #454545;
  232. font-size: 32rpx;
  233. line-height: 1.5;
  234. font-weight: bold;
  235. }
  236. .paddre {
  237. margin-top: 5rpx;
  238. color: #666;
  239. font-size: 24rpx;
  240. line-height: 1.5;
  241. }
  242. }
  243. }
  244. .pam-local {
  245. width: 30rpx;
  246. height: 36rpx;
  247. margin-top: 60rpx;
  248. }
  249. }
  250. .pam-main {
  251. margin-top: 97rpx;
  252. padding-top: 30rpx;
  253. height: 380rpx;
  254. background: #fff;
  255. box-sizing: border-box;
  256. .pm-title {
  257. padding-left: 40rpx;
  258. color: #454545;
  259. font-size: 30rpx;
  260. line-height: 1.5;
  261. }
  262. .pfooter {
  263. margin-top: 60rpx;
  264. padding-left: 40rpx;
  265. padding-top: 40rpx;
  266. color: #666;
  267. font-size: 24rpx;
  268. line-height: 1.5;
  269. }
  270. .u-border-bottom,
  271. .u-border-top {
  272. border-color: #eee !important;
  273. }
  274. .pm-write {
  275. display: flex;
  276. height: 60rpx;
  277. padding-left: 40rpx;
  278. margin-top: 70rpx;
  279. .font {
  280. height: 60rpx;
  281. line-height: 60rpx;
  282. font-size: 30rpx;
  283. color: #454545;
  284. font-weight: bold;
  285. }
  286. .num {
  287. margin-left: 20rpx;
  288. line-height: 60rpx;
  289. height: 60rpx;
  290. .pr-num {
  291. font-size: 68rpx;
  292. line-height: 70rpx;
  293. min-height: 70rpx;
  294. height: 70rpx;
  295. color: #454545;
  296. }
  297. }
  298. }
  299. }
  300. .pac-cont {
  301. display: flex;
  302. justify-content: space-between;
  303. align-items: center;
  304. margin-top: 30rpx;
  305. .pac-left {
  306. display: flex;
  307. .pcfont {
  308. font-size: 24rpx;
  309. color: #666;
  310. height: 30rpx;
  311. line-height: 30rpx;
  312. }
  313. .pcline {
  314. height: 28rpx;
  315. width: 2rpx;
  316. margin-left: 20rpx;
  317. background: #ccc;
  318. }
  319. .pc-aplay {
  320. padding-left: 40rpx;
  321. margin-left: 20rpx;
  322. font-size: 24rpx;
  323. height: 30rpx;
  324. line-height: 30rpx;
  325. color: #999;
  326. background: url(../../static/page/aplay.png) no-repeat left center;
  327. background-size: 30rpx 30rpx;
  328. }
  329. }
  330. .pac-link {
  331. color: #1783FF;
  332. font-size: 24rpx;
  333. height: 30rpx;
  334. line-height: 30rpx;
  335. cursor: pointer;
  336. }
  337. }
  338. .pac-list {
  339. display: flex;
  340. display: none;
  341. justify-content: space-between;
  342. position: absolute;
  343. width: 100%;
  344. left: 0;
  345. right: 0;
  346. bottom: 0;
  347. padding: 14rpx;
  348. height: 415rpx;
  349. background: #f7f7f7;
  350. box-sizing: border-box;
  351. .pl-left {
  352. width: 537rpx;
  353. }
  354. .p-num {
  355. display: flex;
  356. justify-content: center;
  357. align-items: center;
  358. height: 88rpx;
  359. margin: 0;
  360. border: none;
  361. border-radius: 5rpx;
  362. background: #fff;
  363. font-size: 18px;
  364. color: #454545;
  365. font-weight: bold;
  366. &:after {
  367. border: none;
  368. }
  369. }
  370. .pleft-num {
  371. display: flex;
  372. justify-content: space-between;
  373. flex-wrap: wrap;
  374. .p-num {
  375. width: 170rpx;
  376. &.p-mar {
  377. margin-top: 14rpx;
  378. }
  379. }
  380. }
  381. .pleft-btom {
  382. display: flex;
  383. justify-content: space-between;
  384. margin-top: 14rpx;
  385. .p-num {
  386. width: 170rpx;
  387. }
  388. .pu-zero {
  389. width: 354rpx;
  390. margin-right: 14rpx;
  391. }
  392. }
  393. .pl-right {
  394. width: 170rpx;
  395. .pr-del {
  396. background: #fff url(../../static/page/del.png) no-repeat center center;
  397. background-size: 48rpx 34rpx;
  398. }
  399. .pr-sure {
  400. flex: 1;
  401. height: 290rpx;
  402. margin-top: 14rpx;
  403. color: #caf2d8;
  404. background: #ace4c1;
  405. }
  406. }
  407. }
  408. }
  409. </style>