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.

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