123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881 |
- <template>
- <view>
- <ujp-navbar title="确认订单"></ujp-navbar>
- <!-- 地址 -->
- <view class="address">
- <!-- 填写地址 -->
- <view class="fill-address" @click="showPopup">
- <view class="icon">
- <img src="@/assets/img/riFill-add-circle-fill@3x.png" alt="">
- </view>
- <view class="text">
- 填写收货地址
-
- <!-- https://blog.csdn.net/a472066275/article/details/103401969
- -->
- </view>
- <view class="right-icon">
- <u-icon name="arrow-right" color="#cccccc" size="24"></u-icon>
- </view>
- </view>
- <!-- 获取地址 -->
- <view class="get-address" v-if="false">
- <view class="icon">
- <img src="@/assets/img/riFill-wechat-fill@3x.png" alt="">
- </view>
- <view class="text">
- 一键获取微信地址
- </view>
- <view class="right-icon">
- <u-icon name="arrow-right" color="#cccccc" size="24"></u-icon>
- </view>
- </view>
- </view>
-
- <!-- 已填写 -->
- <view class="filled" @click="showPopup">
- <view class="filled-address">
- <view class="address1" v-if="false">
- 湖北省荆州市沙市区朝阳街道
- </view>
- <view class="address2">
- {{deliveryAddress?deliveryAddress:'未填写详细地址'}}
- </view>
- <view class="infos">
- <view class="name">
- {{receiver?receiver:'未填写收货人姓名'}}
- </view>
- <view class="tel">
- {{contactPhone?contactPhone:'未填写收货人手机号'}}
- </view>
- </view>
- </view>
-
- <view class="icon">
- <u-icon name="arrow-right" color="#cccccc" size="24"></u-icon>
- </view>
- </view>
-
-
- <!-- 商品信息 -->
- <view class="commodity-infos">
- <!-- 图片 -->
- <view class="picture">
- <img v-if="info.mallProduct.pic" :src="info.mallProduct.pic" alt="">
- <img v-else src="@/assets/img/chargesite_default.png" ></img>
- </view>
- <!-- 信息 -->
- <view class="infos">
- <view class="title">
- {{info.mallProduct.name}}
- </view>
- <view class="name">
-
- </view>
- <view class="price">
- {{info.mallProductPrice}}元
- </view>
- </view>
- <!-- 数量 -->
- <view class="amount">
-
- </view>
- </view>
- <!-- 订单金额 -->
- <view class="order-amount" v-if="priceAttrList.length">
- <view class="title">
- 选配
- </view>
- <view class="infos">
-
- <template v-for="(item,i) in priceAttrList" >
-
- <view class="infos-item" :key="i">
- <view class="item-title">
- {{item.attribute.name}}
- </view>
- <view class="item-value item-value-end">
- <view v-for="(option , oindex) in item.options" :key="i+'__'+oindex">
- {{option.label}} <span style="margin-left: 8px;" v-if="option.price">{{option.price}}元</span>
- </view>
-
- </view>
-
- </view>
- </template>
- </view>
- </view>
- <!-- 订单金额 -->
- <view class="order-amount">
- <view class="title">
- 订单金额
- </view>
- <view class="infos">
- <view class="item">
- <view class="item-title">
- 商品金额
- </view>
- <view class="item-value">
- {{info.mallProductPrice}}元
- </view>
- </view>
-
-
- <view class="item" v-if="false">
- <view class="item-title">
- 优惠金额
- </view>
- <view class="item-value">
- 0元
- </view>
- </view>
- <view class="item">
- <view class="item-title">
- 运费
- </view>
- <view class="item-value">
- 包邮
- </view>
- </view>
- <view class="item">
- <view class="item-title">
- 合计
- </view>
- <view class="item-value">
- {{mallProductOrder.price}}元
- </view>
- </view>
- </view>
- </view>
- <!-- 支付方式 -->
- <view class="payment">
- <view class="title">
- 支付方式
- </view>
- <radio-group @change="radioChange">
- <view class="way">
- <view class="way-name">
- <text><img src="@/assets/img/riFill-wechat-pay-fill@3x.png" alt=""></text>
- 微信支付
- </view>
- <view class="way-radio">
- <label class="radio">
- <radio value="0" name="abc" :checked="submitType === '0'" /><text></text>
- </label>
- </view>
- </view>
- <view class="way">
- <view class="way-name">
- <text><img src="@/assets/img/ze-alipay Copy@3x.png" alt=""></text>
- 支付宝
- </view>
- <view class="way-radio">
- <label class="radio">
- <radio value="1" name="abc" :checked="submitType === '1'" /><text></text>
- </label>
- </view>
- </view>
- </radio-group>
- </view>
- <!-- 底部 -->
- <view class="bottom">
- <view class="unpaid">
- 待支付: {{mallProductOrder.price}}元
- </view>
- <view class="btn" @click="submit">
- <button class="submit">
- 提交订单
- </button>
- </view>
- </view>
- <!-- 填写收货地址 -->
- <u-popup v-model="show" mode="center" :closeable="true">
- <view class="address-popup">
- <view class="headline">
- 填写收货地址
- </view>
- <view class="infos">
- <view class="item">
- <view class="item-title">
- 收货人
- </view>
- <view class="item-value" style="border-bottom: 1px solid #9E9E9E;">
- <input type="text" v-model="receiverTemp" placeholder="请输入收货人姓名">
- </view>
- </view>
- <view class="item">
- <view class="item-title">
- 手机号码
- </view>
- <view class="item-value" style="border-bottom: 1px solid #9E9E9E;">
- <input type="text" v-model="contactPhoneTemp" placeholder="请输入收货人手机号">
- </view>
- </view>
- <view class="item" v-if="false">
- <view class="item-title">
- 所在区域
- </view>
- <view class="item-value" style="border: 1px solid #9E9E9E;">
- <input type="text" placeholder="请选择省/市/区">
-
- </view>
- <view class="icon">
- <u-icon name="arrow-right" color="#cccccc" size="24"></u-icon>
- </view>
- </view>
-
- <view class="item">
- 详细地址
- <view class="icon" @click="getPoint">
-
- <view class="img">
- <img src="@/assets/img/riLine-map-pin-line@3x.png" alt="">定位
- </view>
- <view class="text">
-
- </view>
- </view>
-
- </view>
- <view class="item" style="border: 1px solid #9E9E9E;">
-
- <u-input type="textarea" placeholder="请输入详细地址" v-model="deliveryAddressTemp">
- </u-input>
-
- </view>
- </view>
- <!-- 保存 -->
- <button class="save" @click="closePopup">保存并使用</button>
- </view>
-
-
- </u-popup>
- <u-modal v-model="showModel" :show-cancel-button="true" @confirm="confirm"
- confirm-text="支付成功?" title="扫码支付">
- <view style="
- text-align: center;
- ">
- <img id="qrcode2" :src="qrCodeImg">
- </view>
- <view style="
- text-align: center;
- ">请使用支付宝扫码</view>
-
- </u-modal>
- <img id="qrcode" style="display: none;">
-
-
- </view>
- </template>
- <script>
- import * as WxJsApi from '@/utils/wxJsApi.js'
- import * as API from '@/apis/mall.js'
- import {
- wxPayJs
- } from '@/utils/wxpay'
- import QRCode from 'qrcodejs2'
- import {
- newDate,checkPhone,
- convertCanvasToImage,
- } from '@/utils'
- import MapLoader from '@/utils/AMap'
- export default {
- data() {
- return {
- show:false,
- id:"",
- opinions:"",
- mallProductOrder:{},
- priceAttrList:{},
- info:{
- mallProduct:{},
- mallProductAttributeList:[],
- mallProductOptionList:[],
- mallProductPrice:0,
-
- },
- receiver:"",
- contactPhone:"",
- deliveryAddress:"",
- receiverTemp:"",
- contactPhoneTemp:"",
- deliveryAddressTemp:"",
- submitForm:{},
- submitType:"0",
- qrCodeImg: "",
- showModel:false,
- outOrderNo:"",
-
- }
- },
- onLoad(op) {
- this.personInfo = this.carhelp.getPersonInfo()
-
- if (op.id) {
- this.id = op.id;
- this.opinions=op.opinions
- this.onLoadApi()
- this.getDetail()
- }
-
-
-
- },
- methods: {
- getPoint() {
- var _this = this;
- WxJsApi.getLocation().then((res) => {
-
-
- var lnglatXY =[parseFloat(res.longitude),parseFloat(res.latitude)]
-
-
- if (res.errMsg != 'getLocation:ok') {
- uni.showToast({
- title: res
- })
- } else {
-
-
- }
- MapLoader().then(AMap => {
- AMap.service('AMap.Geocoder', function() {
- let geocoder = new AMap.Geocoder({});
- geocoder.getAddress(lnglatXY, function(status, result) {
- console.log(lnglatXY);
- console.log(status, result);
- if (status === 'complete' && result.info === 'OK') {
- var address = result.regeocode.formattedAddress;
- console.log(address);
- _this.deliveryAddressTemp = address;
- } else {
- uni.showToast({
- title: '无法获取定位'
- })
-
- }
- });
- });
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
-
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- confirm() {
-
- uni.redirectTo({
- url: "/pages/store/paymentSuccess?id=" + this.outOrderNo
- })
- },
- radioChange: function(evt) {
-
- this.submitType=evt.detail.value
-
- },
- init(){
- if(this.deliveryAddress){
-
- }else{
- this.showPopup()
- }
-
- },
- showPopup(){
- this.show=true;
- this.receiverTemp=this.receiver
- this.contactPhoneTemp=this.contactPhone
- this.deliveryAddressTemp=this.deliveryAddress
- },
- closePopup(){
- this.show=false;
- this.receiver=this.receiverTemp
- this.contactPhone=this.contactPhoneTemp
- this.deliveryAddress=this.deliveryAddressTemp
- },
- submit(){
- var type=this.submitType
- if(!this.receiver){
- uni.showToast({
-
- title: "请输入收货人姓名"
- })
- return
- }
- if(!this.contactPhone){
- uni.showToast({
-
- title: "请输入收货人手机号码"
- })
- return
- }
-
- var checkPhoneResult = checkPhone(this.contactPhone);
-
- if (checkPhoneResult !== true) {
- uni.showToast({
- title: checkPhoneResult,
- })
- return;
- }
-
- if(!this.deliveryAddress){
- uni.showToast({
-
- title: "请输入详细地址"
- })
- return
- }
-
- if (type == 0) {
- this.wxpy()
- }
- if (type == 1) {
- this.alpy()
- }
-
- },
-
- alpy() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- var listcanvas = document.getElementsByTagName('canvas')
-
- if (listcanvas.length > 0) {
- document.getElementById("qrcode").removeChild(document.getElementsByTagName('canvas')[0]);
- }
- API.tradePrecreatePay({
- productId: this.id,
- opinions:this.opinions,
- buyNum:1,
- receiver:this.receiver,
- contactPhone:this.contactPhone,
- deliveryAddress:this.deliveryAddress,
- }).then((response) => {
-
- let qrcode = new QRCode('qrcode', {
- width: 200,
- height: 200,
- text: response.data.qr_code,
- correctLevel: QRCode.CorrectLevel.M,
-
- })
- this.outOrderNo = response.data.outOrderNo;
- var canvas = document.getElementsByTagName('canvas')[0];
- this.qrCodeImg = convertCanvasToImage(canvas);
- uni.hideLoading()
- this.showModel = true
-
- }).catch(error => {
- uni.showToast({
-
- title: error
- })
- })
- },
- wxpy() {
- API.wxJsapiPay({
- productId: this.id,
- opinions:this.opinions,
- buyNum:1,
- receiver:this.receiver,
- contactPhone:this.contactPhone,
- deliveryAddress:this.deliveryAddress,
- }).then((response) => {
- this.submitForm = response.data
- wxPayJs(this.submitForm);
-
- }).catch(error => {
- uni.showToast({
- title: error
- })
- })
-
- },
- getDetail(){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.mallDetails({
- id:this.id
- }).then((res) => {
- uni.hideLoading();
- this.info=res.data
-
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- onLoadApi(){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
-
- API.orderMessage({
- productId:this.id,
- opinions:this.opinions,
- buyNum:1,
- }).then((res) => {
- uni.hideLoading();
- this.mallProductOrder=res.data.mallProductOrder;
- this.priceAttrList=res.data.priceAttrList;
-
- this.receiver=this.personInfo.realName
- this.contactPhone=this.personInfo.phone
-
- if(res.data.lastReceiver){
- this.receiver=res.data.lastReceiver
- this.contactPhone=res.data.lastContactPhone
- this.deliveryAddress=res.data.lastDeliveryAddress
- }
- this.init();
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- padding-bottom: 100px;
- }
- //地址
- .address {
- background-color: #fff;
- margin: 24rpx;
- border-radius: 8px;
- .fill-address,
- .get-address {
- padding: 24rpx;
- display: flex;
- align-items: center;
- .icon {
- width: 40rpx;
- height: 40rpx;
- img {
- width: 100%;
- height: 100%;
- }
- }
- .text {
- color: rgba(16, 16, 16, 1);
- margin-left: 8rpx;
- }
- .right-icon {
- margin-left: auto;
- }
- }
- }
- .item-value-end{
- text-align: end;
-
- }
- // 已填写
- .filled {
- background-color: #fff;
- margin: 24rpx;
- padding: 24rpx;
- border-radius: 8px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .filled-address {
- .address1 {
- color: rgba(51, 51, 51, 1);
- font-size: 24rpx;
- }
- .address2 {
- color: rgba(51, 51, 51, 1);
- margin-top: 16rpx;
- font-weight: bold;
- }
- .infos {
- display: flex;
- font-size: 12px;
- margin-top: 16rpx;
- .tel {
- margin-left: 16rpx;
- }
- }
- }
- }
- // 商品信息
- .commodity-infos {
- background-color: #fff;
- margin: 24rpx;
- padding: 24rpx;
- display: flex;
- align-items: center;
- // 图片
- .picture {
- width: 152rpx;
- height: 152rpx;
- border-radius: 4px;
- img {
- width: 100%;
- height: 100%;
- }
- }
- // 信息
- .infos {
- margin-left: 16rpx;
- .title {
- color: rgba(51, 51, 51, 1);
- font-size: 32rpx;
- font-weight: bold;
- }
- .name {
- color: rgba(119, 119, 119, 1);
- font-size: 24rpx;
- margin-top: 8rpx;
- }
- .price {
- color: rgba(16, 16, 16, 1);
- font-size: 32rpx;
- margin-top: 24rpx;
- }
- }
- // 数量
- .amount {
- color: rgba(51, 51, 51, 1);
- font-size: 32rpx;
- margin-left: auto;
- }
- }
- // 订单金额
- .order-amount {
- margin: 24rpx;
- padding: 32rpx 24rpx;
- background-color: #fff;
- .title {
- color: rgba(51, 51, 51, 1);
- font-size: 32rpx;
- margin-bottom: 32rpx;
- font-weight: bold;
- }
- .item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 24rpx;
- .item-title {
- color: rgba(51, 51, 51, 1);
- }
- .item-value {
- color: rgba(51, 51, 51, 1);
- font-size: 32rpx;
- font-weight: bold;
- }
-
- }
- }
- // 支付方式
- .payment {
- margin: 24rpx;
- padding: 32rpx 24rpx;
- background-color: #fff;
- .title {
- color: rgba(51, 51, 51, 1);
- font-size: 32rpx;
- margin-bottom: 32rpx;
- font-weight: bold;
- }
- .way {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 24rpx;
- .way-name {
- display: flex;
- align-items: center;
- text {
- margin-right: 16rpx;
- img {
- width: 48rpx;
- height: 48rpx;
- vertical-align: middle;
- }
- }
- }
- ::v-deep.uni-radio-input-checked {
- background-color: #00b962 !important;
- }
- ::v-deep.uni-radio-input {
- width: 40rpx !important;
- height: 40rpx !important;
- }
- }
- }
- // 底部
- .bottom {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: #fff;
- padding: 24rpx 32rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .unpaid {
- color: rgba(16, 16, 16, 1);
- font-size: 40rpx;
- font-weight: bold;
- }
- .submit {
- width: 338rpx;
- height: 96rpx;
- background-color: rgba(0, 185, 98, 1);
- color: rgba(255, 255, 255, 1);
- font-size: 36rpx;
- border-radius: 50px;
- }
- }
- // 填写地址
- .address-popup{
- padding: 48rpx;
- width: 640rpx;
- border-radius: 8px;
-
- .headline{
- text-align: center;
- color: rgba(51, 51, 51, 1);
- font-size: 36rpx;
- font-weight: bold;
- }
- .infos{
- margin-top: 70rpx;
- .item{
- display: flex;
- align-items: center;
- margin-bottom: 48rpx;
- .item-title{
- width: 112rpx;
- color: rgba(16, 16, 16, 1);
- }
- .item-value{
- display: flex;
- align-items: center;
- margin-left: 40rpx;
- display: flex;
-
-
- }
- .item-value-end{
- text-align: end;
-
- }
-
- }
- .icon{
- text-align: center;
- color: rgba(22, 119, 255, 1);
- margin-left: auto;
- img{
- width: 32rpx;
- height: 32rpx;
- }
- .text{
- font-size: 20rpx
- }
- }
- }
- // 保存
- .save{
- border-radius: 4px;
- background-color: rgba(0, 185, 98, 1);
- color: rgba(255, 255, 255, 1);
- font-size: 16px;
- height: 80rpx;
- }
- }
- ::v-deep.u-mode-center-box{
- border-radius: 8px !important;
- }
- uni-input{
- font-size: 14px;
- color: #777777;
-
- }
- </style>
|