| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494 |
- <template>
- <view class="login-main">
- <view style="width: 100%">
- <view style="width: 100%; height: 270rpx">
- <image class="img" src="../../static/images/payBack.png" style="width: 100%; height: 100%"></image>
- </view>
- </view>
- <view class="main">
- <view class="login-main-content">
- <image class="img" :src="shopInfo.shopLogoUrl
- ? shopInfo.shopLogoUrl
- : '/static/images/error.jpeg'
- " mode=""></image>
- <h4 class="shopName">
- {{ shopInfo ? shopInfo.shopName : "" }}
- </h4>
- </view>
- <view class="login-contont">
- <view class="uInput">
- <u-input placeholder="请输入金额" border="bottom" :fontSize="40" type="digit"
- @change="validateInput($event, 1)" v-model="price" :customStyle="inpustyle">
- <span slot="prefix" style="font-size: 30px">¥</span>
- </u-input>
- </view>
- <view class="login-contont-button">
- <button class="btn" @click="Pay">立即支付</button>
- <view style="padding: 0px 30rpx">
- <view style="margin-top: 66rpx; background: #fff7f6">
- <u-cell-group :border="false">
- <u-cell title="代金券折扣" :value="couponList.length + '个券可使用'" :border="false" isLink
- @click="voucher"></u-cell>
- </u-cell-group>
- </view>
- <view style="margin-top: 20rpx; font-size: 26rpx">
- 支付成功后,次日将有随机奖励红包以及店铺代金券,可抵现金花,AI天枢云小程序领取
- </view>
- </view>
- </view>
- </view>
- </view>
- <u-popup :show="showPopup" mode="bottom" :round="20">
- <view class="coupon-popup">
- <view class="popup-header">
- <text class="title">店铺代金券</text>
- <u-icon name="close" size="22" @click="showPopup = false" />
- </view>
- <view class="coupon-list">
- <view class="coupon-item" :class="item.status === 0 ? 'disabled' : 'active'"
- v-for="(item, index) in couponList" :key="index" @click="selectCoupon(index)">
- <view class="left">
- <view class="tag" :class="item.type === 1 ? 'independent' : 'chain'">
- {{ item.type === 1 ? '独立券' : '连锁券' }}
- </view>
- <view class="price">
- <text class="yen">¥</text>
- <text class="num">{{ item.price }}</text>
- <text class="tip">{{ item.desc }}</text>
- </view>
- <view class="info">
- <text>{{ item.time }}</text>
- <text>{{ item.scope }}</text>
- </view>
- </view>
- <view class="right">
- <u-radio :checked="selectIndex === index" disabled :custom-style="radioStyle" />
- </view>
- </view>
- </view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import api from "@/api/index.js";
- import { requestConfig } from "@/app.config.js";
- export default {
- data() {
- return {
- showPopup: false,
- requestConfig: requestConfig,
- code: "",
- appid: "",
- value: "",
- userInfo: {},
- inpustyle: {
- fontWeight: "bold",
- fontSize: "40px",
- },
- price: null,
- shopId: "",
- shopInfo: {},
- localUserInfo: {},
- couponList: []
- };
- },
- onLoad(options) {
- this.shopId = options.shopId;
- localStorage.setItem("shopId", this.shopId);
- let info = localStorage.getItem("weChatUserInfo");
- this.localUserInfo = JSON.parse(info);
- if (this.localUserInfo) {
- this.getShopInfo();
- } else {
- this.getInfo();
- this.getVoucher();
- }
- },
- methods: {
- getVoucher() {
- api
- .byStore({
- storeId: '2018881434293329922',
- })
- .then((res) => {
- if (res.code == 200) {
- this.couponList = res.data;
- } else {
- uni.$u.toast(res.msg);
- }
- });
- },
- voucher() {
- this.showPopup = true;
- },
- getInfo() {
- let code = this.GetQueryString("code");
- localStorage.removeItem("token");
- localStorage.removeItem("weChatUserInfo");
- api
- .weChatH5Login({
- code: code,
- })
- .then((res) => {
- console.log(res);
- if (res.code == 200) {
- this.userInfo = res.data;
- localStorage.setItem("token", this.userInfo.token);
- localStorage.setItem(
- "weChatUserInfo",
- JSON.stringify(this.userInfo),
- );
- if (this.userInfo.bindPhoneStatus == 0) {
- this.showPhone = true;
- } else {
- this.showPhone = false;
- }
- this.getShopInfo();
- } else {
- uni.$u.toast("获取微信登录信息失败,请重新登录!");
- }
- });
- },
- async getShopInfo() {
- api
- .getStoreInfoByScan({
- shopId: this.shopId,
- })
- .then((res) => {
- if (res.code == 200) {
- this.shopInfo = res.data;
- } else {
- uni.$u.toast(res.msg);
- }
- });
- },
- async Pay() {
- uni.showLoading({
- title: "支付中",
- });
- if (!this.price) {
- uni.$u.toast("请输入支付金额!");
- }
- api
- .payOrder({
- shopType: this.shopInfo.shopType,
- shopUserId: this.shopInfo.shopUserId,
- shopId: this.shopInfo.shopId,
- payAmount: Number(this.price),
- payWay: 6,
- userId: this.localUserInfo.userId
- })
- .then((res) => {
- if (res.code == 200) {
- WeixinJSBridge.invoke(
- "getBrandWCPayRequest",
- {
- // 公众号名称,由商户传入
- appId: res.data.appId,
- // 时间戳,自1970年以来的秒数
- timeStamp: res.data.timeStamp,
- // 随机串
- nonceStr: res.data.nonceStr,
- package: res.data.package,
- // 微信签名方式:
- signType: res.data.signType,
- // 微信签名
- paySign: res.data.paySign,
- },
- function (res) {
- if (res.err_msg == "get_brand_wcpay_request:ok") {
- // 使用以上方式判断前端返回,
- // 微信团队郑重提示:
- uni.hideLoading();
- // window.location.href = requestConfig.redirectOpen;
- uni.navigateTo({
- url: `/pages/index/paySuccess`,
- });
- // res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
- } else {
- uni.hideLoading();
- uni.$u.toast("支付失败!");
- }
- },
- );
- } else {
- uni.$u.toast(res.msg);
- }
- }).catch((err) => {
- uni.hideLoading();
- let msg = err.msg || "";
- let errStr = msg.match(/[\u4e00-\u9fa5\/]+/)?.[0] || "支付失败";
- uni.$u.toast(errStr);
- });
- },
- GetQueryString(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) return unescape(r[2]);
- return null;
- },
- validateInput(e, num) {
- const inputTypeNum = /[^\d]/g; //数字
- // switch (num) {
- // case 1:
- // //要写nextTick 不然无效
- // this.$nextTick(() => {
- // this.price = e.replace(inputTypeNum, "");
- // });
- // break;
- // }
- },
- },
- };
- </script>
- <style lang="scss">
- .coupon-popup {
- padding: 30rpx;
- height: 1000rpx;
- box-sizing: border-box;
- }
- .popup-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: 32rpx;
- font-weight: bold;
- margin-bottom: 30rpx;
- }
- .coupon-list {
- height: calc(100% - 100rpx);
- overflow-y: auto;
- }
- .coupon-item {
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx;
- margin-bottom: 20rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- border: 2rpx solid #eee;
- }
- .coupon-item.active {
- border-color: #ff4d4f;
- background: #fffbf4;
- }
- .coupon-item.disabled {
- opacity: 0.5;
- }
- .left {
- flex: 1;
- }
- .tag {
- font-size: 22rpx;
- color: #fff;
- padding: 4rpx 12rpx;
- border-radius: 6rpx;
- margin-bottom: 12rpx;
- }
- .independent {
- background: #5c8dff;
- }
- .chain {
- background: #ff7d00;
- }
- .price {
- display: flex;
- align-items: baseline;
- margin-bottom: 12rpx;
- }
- .yen {
- font-size: 28rpx;
- color: #ff4d4f;
- }
- .num {
- font-size: 44rpx;
- font-weight: bold;
- color: #ff4d4f;
- margin: 0 10rpx;
- }
- .tip {
- font-size: 24rpx;
- color: #999;
- }
- .info {
- font-size: 24rpx;
- color: #999;
- line-height: 1.6;
- }
- .right {
- padding-left: 20rpx;
- }
- ::v-deep .u-cell__title {
- flex: none !important;
- }
- .main {
- width: 100%;
- background: white;
- height: calc(100% - 280rpx);
- border-radius: 40rpx;
- }
- .shopName {
- font-weight: bold;
- font-size: 36rpx;
- color: #333333;
- }
- /* 修改加载提示框的遮罩层 z-index */
- .uni-loading__mask {
- z-index: 10076;
- }
- /* 修改加载提示框本身的 z-index */
- .uni-loading {
- z-index: 10076;
- }
- .yzm {
- font-weight: 500;
- font-size: 28rpx;
- color: #00d36d;
- }
- .popup {
- height: 300px;
- padding: 20px;
- .footer {
- margin-top: 150rpx;
- .btn {
- width: 100%;
- background: linear-gradient(152deg, #6f9dfd 0%, #1b71f2 100%);
- border-radius: 46rpx;
- border: none;
- }
- }
- .main {
- margin-top: 20rpx;
- }
- .header {
- margin-bottom: 20rpx;
- text-align: center;
- .tip {
- margin-top: 20rpx;
- font-weight: 500;
- font-size: 26rpx;
- color: #ff8b2f;
- }
- }
- }
- .u-radio-group--row {
- justify-content: center;
- }
- .radioText {
- font-weight: 500;
- font-size: 24rpx;
- color: #999999;
- line-height: 34rpx;
- text-align: left;
- font-style: normal;
- }
- .login-main {
- background: url("../../static/images/payBack.png");
- background-size: 100% 100%;
- width: 100%;
- display: flex;
- flex-direction: column;
- /* justify-content: space-between; */
- align-items: center;
- height: 100vh;
- }
- .login-contont-button {
- text-align: center;
- .btn {
- margin-top: 20px;
- width: 95%;
- height: 90rpx;
- background: linear-gradient(152deg, #6f9dfd 0%, #1b71f2 100%);
- border-radius: 44rpx;
- color: #fff;
- }
- }
- .login-contont {
- width: 100%;
- height: 600rpx;
- margin-top: 100rpx;
- .uInput {
- padding: 10px 0px;
- border-bottom: 0.5px solid #97979740;
- }
- .login-contont-info {
- text-align: center;
- .text {
- margin-top: 10px;
- font-weight: 500;
- font-size: 28rpx;
- color: #999999;
- line-height: 40rpx;
- font-style: normal;
- }
- }
- }
- .radio {
- text-align: center;
- margin-top: 10px;
- }
- .login-main-content {
- display: flex;
- flex-direction: row;
- align-items: center;
- padding: 9px 26px;
- .img {
- // margin-top: 70px;
- margin-right: 20rpx;
- width: 44rpx;
- height: 44rpx;
- border-radius: 50%;
- }
- }
- </style>
|