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.

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