123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- <template>
- <view style="overflow: hidden;">
- <payment-pasword ref="paymentPassword" mode="1" @submit="balancePay"></payment-pasword>
- <timer-tips v-if="orders.length" :createtime="orders[0].createtime"></timer-tips>
- <view class="order-list">
- <view v-for="(order,index) in orders" :key="index" class="order-item">
- <view class="order-head">
- <view class="factory-name">{{order.seller.nickname?order.seller.nickname:'省心直供(该厂家暂未设置昵称)'}}</view>
- </view>
- <view class="order-info" @tap="openDetails(order.id)">
- <view class="product-item" v-for="product in order.products_json">
- <view class="product-image">
- <image class="image" :src="product.spec_image|imagesFilter" mode="scaleToFill"></image>
- </view>
- <view class="product-info">
- <view class="row">
- <view class="name">{{product.name}}</view>
- <view class="price">¥{{product.spec_price|priceFilter}}</view>
- </view>
- <view class="row">
- <view class="spec">{{product.spec_name}}</view>
- <view class="num">×{{product.num}}</view>
- </view>
- </view>
- </view>
- </view>
- <view class="total-price">
- 总价 <text class="warning">¥{{order.total_amount}}</text>
- </view>
- </view>
- </view>
- <view class="sum">合计:{{total_amount_sum|priceFilter}}元</view>
- <view class="pay-method">
- <view class="label">请选择支付方式</view>
- <view>
- <view class="item" :class="{'active':pay_method==='alipay'}"
- @tap="pay_method='alipay',pay_provider='alipay'">
- <image class="image" src="../../static/alipay.png" mode="scaleToFill"
- style="width: 50upx;height: 50upx;"></image>支付宝
- </view>
- <view class="item" :class="{'active':pay_method==='wechat'}"
- @tap="pay_method='wechat',pay_provider='wxpay'">
- <image class="image" src="../../static/wxpay.png" mode="scaleToFill"
- style="width: 50upx;height: 50upx;"></image>微信支付
- </view>
- <view class="item" :class="{'active':pay_method==='balance'}" @tap="pay_method='balance'">
- <image class="image" src="../../static/logo.png" mode="scaleToFill"
- style="width: 50upx;height: 50upx;"></image>使用余额({{$store.state.user.money}})
- </view>
- </view>
- <view class="" style="margin-top: 40upx;">
- <button class="pay-btn" type="default" @tap="pay">立即支付</button>
- </view>
- </view>
- </view>
- </template>
- <script>
- import paymentPasword from "@/components/sanshui-payment-password/index.vue"
- export default {
- data() {
- return {
- pay_method: "alipay",
- pay_provider: "alipay",
- orders: [],
- order_no: ""
- }
- },
- components: {
- paymentPasword
- },
- computed: {
- total_amount_sum() {
- return this.orders.reduce((prev, cur) => {
- return prev + Number(cur.total_amount)
- }, 0)
- }
- },
- onLoad(option) {
- this.order_no = option.order_no,
- this.getCashierData();
- },
- methods: {
- getCashierData() {
- this.$http.get({
- url: "/order/cashier",
- data: {
- order_no: this.order_no
- },
- success: (res) => {
- this.orders = res.data.data.map((value) => {
- value.products_json = JSON.parse(value.products_snapshot)
- return value;
- })
- }
- })
- },
- balancePay(e) {
- console.log(e)
- this.$http.post({
- url: '/order/balancePay',
- data: {
- 'order_no': this.order_no,
- 'pay_method': this.pay_method,
- 'amount': this.total_amount_sum,
- 'safe_pass': e.value
- },
- success: (res) => {
- uni.navigateTo({
- url: "/pages/order/order",
- })
- }
- })
- },
- pay() {
- if (this.pay_method !== 'balance') {
- this.$http.get({
- url: '/order/pay',
- data: {
- 'order_no': this.order_no,
- 'pay_method': this.pay_method,
- 'amount': this.total_amount_sum
- },
- success: (res) => {
- uni.requestPayment({
- provider: this.pay_provider,
- orderInfo: res.data.data,
- success: (res) => {
- uni.showModal({
- content: JSON.stringify(res)
- })
- },
- fail: (res) => {
- uni.showModal({
- content: "支付失败",
- })
- }
- })
- }
- })
- } else {
- this.$refs.paymentPassword.modalFun('show');
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .order {
- overflow: hidden;
- }
- .order-list {
- .order-item {
- background: white;
- margin: 20upx;
- padding: 20upx;
- border-radius: 20upx;
- .order-head {
- display: flex;
- justify-content: space-between;
- margin-bottom: 20upx;
- .order-status {
- color: $primary-color;
- font-size: 24upx;
- }
- }
- .factory-name {
- font-size: 28upx;
- font-weight: bold;
- }
- .product-item {
- display: flex;
- .product-image {
- width: 120upx;
- height: 120upx;
- margin-right: 20upx;
- margin-top: 10upx;
- .image {
- width: 120upx;
- height: 120upx;
- }
- }
- .product-info {
- flex-grow: 1;
- font-size: 28upx;
- .name {
- font-size: 28upx;
- white-space: normal;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- }
- .num {
- color: #999999;
- }
- .spec {
- font-size: 26upx;
- background: #CCCCCC;
- color: white;
- padding: 0 10upx;
- border-radius: 10upx;
- }
- }
- .row {
- display: flex;
- justify-content: space-between;
- margin-bottom: 10upx;
- }
- }
- .total-price {
- text-align: right;
- font-size: 28upx;
- padding: 10upx 0;
- .warning {
- color: $primary-color;
- font-weight: bold;
- }
- }
- }
- }
- .sum {
- margin: 20upx;
- font-size: 30upx;
- text-align: right;
- font-weight: bold;
- }
- .pay-method {
- margin: 20upx;
- padding: 20upx;
- background: white;
- .label {
- font-size: 30upx;
- margin-bottom: 20upx;
- }
- .item {
- height: 80upx;
- display: flex;
- align-items: center;
- font-size: 30upx;
- border-bottom: 2upx solid #F5F5F5;
- .image {
- margin-right: 10upx;
- }
- &.active {
- background: url(../../static/gou.png) no-repeat;
- background-size: 40upx 40upx;
- background-position: 600upx 20upx;
- }
- }
- }
- .pay-btn {
- margin: 20upx 0;
- background: $primary-color;
- color: white;
- font-size: 32upx;
- font-weight: bold;
- }
- </style>
|