123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472 |
- <template>
- <view class="content">
- <view class="box">
- <block v-if="JSON.stringify(address) == '{}'">
- <view class="hflex acenter jbetween" @click="addAddr">
- <view class="title">新增收货地址</view>
- <u-icon name="arrow-right" color="#ABABAB" size="11"></u-icon>
- </view>
- </block>
- <block v-else>
- <view class="hflex acenter jbetween" @click="addAddr">
- <view class="hflex acenter">
- <u-icon name="map-fill" color="#506DFF" size="22"></u-icon>
- <view class="vflex" style="padding-left: 16rpx;">
- <view class="hflex acenter">
- <view class="text_style1" style="padding-right: 20rpx;">{{address.name}}</view>
- <view class="text_style1">{{address.phone}}</view>
- </view>
- <view class="text_style2">{{address.address}}</view>
- </view>
- </view>
- <u-icon name="arrow-right" color="#ABABAB" size="11"></u-icon>
- </view>
- </block>
- </view>
- <block v-if="pageList.length == 0">
- <view class="box">
- <view class="title">{{pageData.admin_name}}</view>
- <view class="hflex acenter cell">
- <image :src="pageData.items[item_id].show_image" mode="aspectFill" class="img"></image>
- <view class="img_right">
- <view class="hflex acenter jbetween">
- <view class="item_name text_hide" style="width: 374rpx;">{{pageData.name}}</view>
- <view class="item_name">¥{{pageData.items[item_id].price_selling}}</view>
- </view>
- <view class="hflex jbetween" style="padding: 2rpx 0 0;">
- <view class="norm">{{pageData.items[item_id].goods_spec || ''}}</view>
- <view class="left_text">X{{buy_num}}</view>
- </view>
- </view>
- </view>
- <view class="hflex acenter jbetween">
- <view class="title">订单备注</view>
- <u-input v-model="remarks" inputAlign="right" border="none" placeholder="建议留言前先与商家沟通确认"></u-input>
- </view>
- </view>
-
- </block>
- <block v-if="pageList.length > 0">
- <block v-for="(item,index) in pageList" :key="index">
- <view class="box">
- <view class="title">{{item.nickname}}</view>
- <block v-for="(item2,index2) in item.goods_item" :key="index">
- <view class="hflex acenter cell">
- <image :src="item2.show_image" mode="aspectFill" class="img"></image>
- <view class="img_right">
- <view class="hflex acenter jbetween">
- <view class="item_name text_hide" style="width: 374rpx;">{{item2.name}}</view>
- <view class="item_name">¥{{item2.price_selling}}</view>
- </view>
- <view class="hflex jbetween" style="padding: 2rpx 0 0;">
- <view class="norm">{{item2.goods_spec}}</view>
- <view class="left_text">X{{item2.num}}</view>
- </view>
- </view>
- </view>
- </block>
- <view class="hflex acenter jbetween">
- <view class="title">订单备注</view>
- <u-input v-model="remarks" inputAlign="right" border="none" placeholder="建议留言前先与商家沟通确认"></u-input>
- </view>
- </view>
- </block>
- </block>
- <view class="box" v-if="pageList.length == 0">
- <view class="hflex acenter jbetween">
- <view class="left_text">商品金额</view>
- <view class="right_text">¥{{total}}</view>
- </view>
- <!-- <view class="hflex acenter jbetween cell2">
- <view class="left_text">运费</view>
- <view class="right_text">¥0.00</view>
- </view> -->
- <view class="hflex acenter jend item_bottom">
- <view class="title" style="font-size: 22rpx;">合计:<span class="text_red">¥{{total}}</span></view>
- </view>
- </view>
- <view class="box" v-if="pageList.length > 0">
- <view class="hflex acenter jbetween">
- <view class="left_text">商品金额</view>
- <view class="right_text">¥{{total}}</view>
- </view>
- <!-- <view class="hflex acenter jbetween cell2">
- <view class="left_text">运费</view>
- <view class="right_text">¥{{freight}}</view>
- </view> -->
- <view class="hflex acenter jend item_bottom">
- <view class="title" style="font-size: 22rpx;">合计:<span class="text_red">¥{{total}}</span></view>
- </view>
- </view>
- <view class="box hflex acenter jbetween" style="margin-bottom: 186rpx;">
- <view class="hflex acenter">
- <image src="/static/images/shop/wx_pay.png" class="pay_icon"></image>
- <view class="text_style1">微信支付</view>
- </view>
- <u-radio-group>
- <u-radio activeColor="#506DFF"></u-radio>
- </u-radio-group>
- </view>
- <view class="bottom hflex acenter jend">
- <view class="title" style="font-size: 22rpx;" v-if="pageList.length == 0">合计:<span class="text_blue">¥{{total}}</span></view>
- <view class="title" style="font-size: 22rpx;" v-else>合计:<span class="text_blue">¥{{total}}</span></view>
- <view class="btn" @click="submit">提交订单</view>
- </view>
- </view>
- </template>
- <script>
- import $api from '@/static/js/api.js'
- var that = ''
- export default {
- data() {
- return {
- address: {
- },
- pageData: {},
- pageList: [],
- order_id: '',
- address_id: '',
- pay_no:'',
- total: 0,
- freight: '0.00',
- item_id: '',
- cart_ids: '',
- buy_num: 1,
- remarks: ''
- }
- },
- onLoad(options) {
- that = this
- console.log(options);
- // that.address_id = uni.getStorageSync('address_id')
- /* if(options.address_id) {
- that.address_id = options.address_id
- } */
- if(options.pageData) {
- that.pageData = JSON.parse(options.pageData)
- console.log('that.pageData',that.pageData);
- that.item_id = options.item_id
- that.buy_num = Number(options.buy_num)?Number(options.buy_num):1
- // pageData.items[item_id].goods_spec = $api.resetspec(pageData.items[item_id].goods_spec)
- that.total = (Number(that.pageData.items[that.item_id].price_selling) * that.buy_num).toFixed(2)
- that.pageData.items[that.item_id].goods_spec = $api.resetspec(that.pageData.items[that.item_id].goods_spec)
- } else {
- if(options.data) {
- that.pageList = JSON.parse(options.data)
- that.cart_ids = options.cart_ids
- that.count()
- for(var i=0;i<that.pageList.length;i++) {
- for(var j=0;j<that.pageList[i].goods_item.length;j++) {
- that.pageList[i].goods_item[j].goods_spec = $api.resetspec(that.pageList[i].goods_item[j].goods_spec)
- }
- }
- }
- }
- },
- onShow() {
- that.getAddr()
- },
- methods: {
- getData() {
- $api.req({
- url: '/data/api.Order/order_info',
- method: 'POST',
- data: {
- order_id: that.order_id,
- }
- }, function(res) {
- if(res.code == 1) {
- $api.info(res.info)
- that.pageData = res.data
- }
- })
- },
- count() {
- console.log(that.pageList);
- for(var i=0;i<that.pageList.length;i++) {
- for(var j=0;j<that.pageList[i].goods_item.length;j++) {
- console.log(that.pageList[i].goods_item[j]);
- if(that.pageList[i].goods_item[j].num != 0) {
- that.total += Number(that.pageList[i].goods_item[j].price_selling) * Number(that.pageList[i].goods_item[j].num)
- } else {
- that.total += Number(that.pageList[i].goods_item[j].price_selling) * Number(that.pageList[i].goods_item[j].stock_sales)
- }
- }
- }
- that.total = that.total.toFixed(2)
- },
- getAddr() {
- // that.address_id = uni.getStorageSync('address_id')
- // if(that.address_id == '') {
- // return
- // }
- $api.req({
- url: '/data/api.User/address_list'
- }, function(res) {
- if(res.code == 1) {
- for(var i=0;i<res.data.data.length;i++) {
- that.address = res.data.data[0]
- that.address_id = that.address.id
- }
- }
- })
- },
- addAddr() {
- $api.jump('/page_shop/pages/address/list?select=true')
- },
- submit() {
- if(JSON.stringify(that.address) == '{}') {
- $api.info("请先选择地址")
- return
- }
- if(!that.address.name) {
- $api.info("请先选择地址")
- return
- }
- if(that.item_id) {
- $api.req({
- url: '/data/api.Order/order_create',
- method: 'POST',
- data: {
- admin_id: that.pageData.admin_id,
- item_id: that.pageData.items[that.item_id].id,
- num: that.buy_num,
- address_id: that.address_id,
- order_remark: that.remarks
- }
- }, function(res) {
- if(res.code == 1) {
- that.order_id = res.data.order_id
- that.pay_no = res.data.pay_no
- $api.req({
- url: '/data/api.auth.Center/channel',
- method: 'POST',
- data: {
- type: 2,
- from: 1
- }
- }, function(res) {
- if(res.code == 1) {
- var pay_code = res.data[0].code
- $api.req({
- url: '/data/api.Order/order_pay',
- method: 'POST',
- data: {
- pay_code: pay_code,
- pay_no: that.pay_no,
- type: 'wechat'
- }
- }, function(res) {
- if(res.code == 1) {
- wx.requestPayment({
- timeStamp: res.data.pay.timeStamp,
- nonceStr: res.data.pay.nonceStr,
- package: res.data.pay.package,
- signType: 'MD5',
- paySign: res.data.pay.paySign,
- success (res) {
- $api.jump('/page_shop/pages/order/paySuccess?id=' +that.order_id ,2)
- },
- fail (res) {
- console.log(res);
- }
- })
- }
- })
- }
- })
- }
- })
- } else {
- $api.req({
- url: '/data/api.Order/crat_create',
- method: 'POST',
- data: {
- cart_ids: that.cart_ids,
- address_id: that.address_id,
- order_remark: that.remarks
- }
- }, function(res) {
- if(res.code == 1) {
- that.pay_no = res.data
- $api.req({
- url: '/data/api.auth.Center/channel',
- method: 'POST',
- data: {
- type: 2,
- from: 1
- }
- }, function(res) {
- if(res.code == 1) {
- var pay_code = res.data[0].code
- $api.req({
- url: '/data/api.Order/order_pay',
- method: 'POST',
- data: {
- pay_code: pay_code,
- pay_no: that.pay_no,
- type: 'wechat'
- }
- }, function(res) {
- if(res.code == 1) {
- wx.requestPayment({
- timeStamp: res.data.pay.timeStamp,
- nonceStr: res.data.pay.nonceStr,
- package: res.data.pay.package,
- signType: 'MD5',
- paySign: res.data.pay.paySign,
- success (res) {
- $api.jump('/page_shop/pages/order/paySuccess?id=' +that.order_id ,2)
- },
- fail (res) { }
- })
- }
- })
- }
- })
- }
- })
- }
- }
- },
- }
- </script>
- <style lang="scss" scoped>
- .content::v-deep {
- background-color: #F4F4F4;
- .box {
- background: #FFFFFF;
- border-radius: 10px;
- margin: 20rpx auto 0;
- width: 690rpx;
- box-sizing: border-box;
- padding: 34rpx 20rpx;
- .title {
- font-size: 32rpx;
- font-weight: 500;
- color: #222222;
- line-height: 44rpx;
- }
- .text_style1 {
- font-size: 28rpx;
- font-weight: 500;
- color: #222222;
- line-height: 40rpx;
- }
- .text_style2 {
- font-size: 26rpx;
- font-weight: 400;
- color: #888888;
- line-height: 36rpx;
- }
- .cell {
- padding: 20rpx 0 32rpx;
- }
- .cell2 {
- padding: 32rpx 0 20rpx;
- }
- .img {
- width: 160rpx;
- height: 160rpx;
- border-radius: 24rpx;
- }
- .img_right {
- width:calc(100% - 160rpx);
- padding-left: 20rpx;
- .item_name {
- font-size: 30rpx;
- font-weight: 400;
- color: #222222;
- line-height: 42rpx;
- }
- .norm {
- max-width: 288rpx;
- width: max-content;
- // height: 42px;
- background: #F5F5F5;
- border-radius: 12rpx;
- box-sizing: border-box;
- padding: 12rpx 12rpx 5rpx;
- font-size: 20rpx;
- font-weight: 400;
- color: #888888;
- line-height: 28rpx;
- text-overflow: ellipsis;
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- box-orient: vertical;
- line-clamp: 2;
- -webkit-line-clamp: 2;
- }
-
- }
- .left_text {
- font-size: 24rpx;
- font-weight: 500;
- color: #888888;
- line-height: 28rpx;
- }
- .right_text {
- font-size: 24rpx;
- font-weight: bold;
- color: #222222;
- line-height: 28rpx;
- }
- .item_bottom {
- padding-top: 22rpx;
- border-top: 1rpx solid #F4F4F4;
- }
- .text_red {
- font-weight: bold;
- color: #EE5850;
- }
- .pay_icon {
- width: 48rpx;
- height: 48rpx;
- margin-right: 20rpx;
- }
- .check_icon {
- width: 32rpx;
- height: 32rpx;
- }
- }
- .u-radio-group {
- flex: 0 !important;
- }
- .bottom {
- width: 100%;
- height: 166rpx;
- background: #FFFFFF;
- z-index: 9;
- position: fixed;
- bottom: 0;
- box-sizing: border-box;
- padding: 8rpx 50rpx 74rpx;
- .title {
- font-size: 24rpx;
- font-weight: 400;
- color: #222222;
- line-height: 34rpx;
- }
- .text_blue {
- font-size: 44rpx;
- color: #5270FF;
- }
- .btn{
- margin-left: 16rpx;
- width: 260rpx;
- height: 84rpx;
- background: #506DFF;
- border-radius: 42rpx;
- text-align: center;
- font-size: 36rpx;
- font-weight: 500;
- color: #FFFFFF;
- line-height: 84rpx;
- }
- }
- }
- </style>
|