123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <scroll-view scroll-y="true" class="scroll-view">
- <view class="list-scroll-view">
- <view class="one_1" @click="toChoose">
- <text class="localicon iconfont icon-dingweixiao"></text>
- <view class="other" v-if="address._id">
- <view class="name">
- <text>{{address.name}},</text>{{address.phone}}
- </view>
- <view class="other_1">
- <text>{{address.province}}</text><text>{{address.city}}</text>
- <text>{{address.area}}</text><text>{{address.address}}</text>
- </view>
- </view>
- <view class="address" v-else><text>请选择一个收货地址</text></view>
- <text class="iconfont icon-jiantouyou"></text>
- </view>
- <view class="one_2">
- <view class="list">
- <view class="list_1">
- <view class="l">
- <text class="iconfont icon-shangdian"></text>
- <text>{{shopInfo.name}}</text>
- </view>
- </view>
- <view class="list_2">
- <view class="l">
- <image class="image" :src="orderInfo.file&&orderInfo.file.length>0?orderInfo.file[0].url:''" mode=""></image>
- </view>
- <view class="c">
- <view class="name">
- {{orderInfo.name}}
- </view>
- </view>
- <view class="r">
- <view class="price">
- {{orderInfo.cost}}
- </view>
- <view class="num">
- ×{{buy_num}}
- </view>
- </view>
- </view>
- <view class="list_3">
- <view class="other">
- <view class="other_1">配送方式</view>
- <view class="other_2"><text class="iconfont icon-duihao"></text>快递配送</view>
- </view>
- <view class="other">
- <view class="other_1">运费</view>
- <view class="other_2">包邮</view>
- </view>
- <view class="other">
- <view class="other_1">订单备注</view>
- <view class="other_3">
- <input type="text" v-model="remarks" placeholder="选填,可填写您与卖家达成一致的要求" />
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="two">
- <view class="two_1">
- <view>尊荣:</view>
- <view>{{costTotal}}</view>
- </view>
- <view class="two_2">
- <text @click="toSubmit">尊荣支付</text>
- </view>
- </view>
- </view>
- <uni-popup ref="popup" background-color="#fff" type="bottom">
- <view class="popup">
- <scroll-view scroll-y="true" class="scroll-view">
- <view class="list" v-for="(item,index) in addressList" :key="index">
- <view class="one">
- <view class="one_1">
- <view class="name">
- <text>{{item.name}},</text>{{item.phone}}
- </view>
- <view class="address">
- <text>{{item.province}}</text><text>{{item.city}}</text>
- <text>{{item.area}}</text><text>{{item.address}}</text>
- </view>
- </view>
- <text class="iconfont icon-jiantouyou"></text>
- </view>
- <view class="two">
- <view class="two_1">
- <checkbox-group @change="toCheckbox">
- <label>
- <checkbox :value="item._id" :checked="item.checked" style="transform:scale(0.7)" />
- 选择地址
- </label>
- </checkbox-group>
- </view>
- <view class="two_2">
- <text class="text" v-if="item.is_default=='1'">默认</text>
- <text @click="toDel(item)" class="iconfont icon-del"></text>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </uni-popup>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- user: {},
- key: '',
- address: {},
- // 商品详情
- orderInfo: {},
- // 店铺详情
- shopInfo: {},
- // 总尊荣
- costTotal: 0,
- // 购买数量
- buy_num: 0,
- // 收货地址
- addressList: [],
- // 备注
- remarks: '',
- };
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `key`, e.key || '');
- that.watchLogin()
- },
- methods: {
- // 监听用户是否登录
- watchLogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: function(res) {
- let user = that.$jwt(res.data);
- that.$set(that, `user`, user);
- that.search()
- },
- fail: function(err) {
- uni.reLaunch({
- url: `/pages/login/index`
- })
- }
- })
- },
- // 查询列表
- async search() {
- const that = this;
- let user = that.user;
- const res = await that.$api(`/address`, 'GET', {
- customer: user._id
- })
- if (res.errcode == '0') {
- that.$set(that, `addressList`, res.data.reverse());
- }
- const arr = await that.$api(`/zrOrder/toMakeOrder`, 'POST', {
- key: that.key
- }, `integral`)
- if (arr.errcode == '0') {
- that.$set(that, `address`, arr.data.address);
- that.$set(that, `orderInfo`, arr.data.goods);
- that.$set(that, `costTotal`, arr.data.costTotal);
- that.$set(that, `shopInfo`, arr.data.shop);
- that.$set(that, `buy_num`, arr.data.buy_num);
- }
- },
- // 选择收货地址
- toChoose() {
- const that = this;
- if (that.addressList.length > 0) {
- that.$refs.popup.open();
- } else {
- uni.showToast({
- title: `暂无收货地址`,
- icon: 'none'
- })
- }
- },
- // 是否选中
- toCheckbox(e) {
- const that = this;
- var addressList = that.addressList;
- var values = e.detail.value;
- for (var i = 0, lenI = addressList.length; i < lenI; ++i) {
- const item = addressList[i]
- if (values.includes(item._id)) {
- that.$set(item, 'checked', true)
- that.$set(that, `address`, item);
- } else {
- that.$set(item, 'checked', false)
- }
- }
- that.$refs.popup.close();
- },
- // 删除收货地址
- toDel(e) {
- const that = this;
- uni.showModal({
- title: '提示',
- content: '确定删除该地址吗?',
- success: async function(res) {
- if (res.confirm) {
- const arr = await that.$api(`/address/${e._id}`, 'DELETE');
- if (arr.errcode == '0') {
- uni.showToast({
- title: '删除信息成功',
- icon: 'none'
- })
- that.search();
- } else {
- uni.showToast({
- title: arr.errmsg,
- icon: 'none'
- })
- }
- }
- }
- });
- },
- // 提交订单
- async toSubmit() {
- const that = this;
- if (that.address) {
- uni.showModal({
- title: '提示',
- content: '确定兑换该商品吗?',
- success: async function(res) {
- if (res.confirm) {
- let data = {
- address: that.address._id,
- shop: that.shopInfo._id,
- goods: that.orderInfo._id,
- buy_num: that.buy_num,
- remarks: that.remarks
- }
- const arr = await that.$api(`/zrOrder`, `POST`, data, `integral`)
- if (arr.errcode == '0') {
- uni.hideLoading();
- uni.showToast({
- title: arr.data.errmsg || '兑换成功',
- icon: 'none'
- })
- uni.reLaunch({
- url: `/pagesIntegral/record/index`
- })
- } else {
- uni.showToast({
- title: arr.data.errmsg || '兑换失败!',
- icon: 'none'
- })
- }
- }
- }
- });
- } else {
- uni.showToast({
- title: `没有收货地址`,
- icon: 'none'
- })
- }
- }
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- position: relative;
- flex-grow: 1;
- background-color: var(--f1Color);
- .one_1 {
- display: flex;
- justify-content: space-between;
- align-items: center;
- width: 100vw;
- padding: 2vw;
- border-bottom: 1vw dashed var(--fcColor);
- .address {
- flex-grow: 1;
- margin: 0 0 0 2vw;
- font-size: var(--font14Size);
- color: var(--f85Color);
- }
- .iconfont {
- font-size: var(--font20Szie);
- }
- .other {
- width: 82vw;
- padding: 0 2vw;
- .name {
- font-size: var(--font16Size);
- }
- .other_1 {
- font-size: var(--font14Size);
- color: var(--f85Color);
- text {
- margin: 0 1vw 0 0;
- }
- }
- }
- }
- .one_2 {
- margin: 2vw 0 0 0;
- .list {
- width: 100vw;
- margin: 2vw 0;
- .list_1 {
- padding: 2vw;
- background-color: var(--mainColor);
- border-bottom: 0.1vw solid var(--fcColor);
- text {
- padding: 0 0 0 1vw;
- }
- }
- .list_2 {
- padding: 2vw;
- display: flex;
- background-color: var(--mainColor);
- .l {
- width: 20vw;
- .image {
- width: 100%;
- height: 20vw;
- border-radius: 5px;
- }
- }
- .c {
- width: 60vw;
- padding: 0 2vw;
- }
- .r {
- width: 15vw;
- text-align: right;
- .price {
- color: var(--fFB1Color);
- }
- }
- }
- .list_3 {
- width: 96vw;
- padding: 2vw;
- background-color: var(--mainColor);
- .other {
- display: flex;
- justify-content: space-between;
- border-bottom: 0.1vw solid var(--fcColor);
- margin: 0 0 2vw 0;
- padding: 2vw 0;
- .other_1 {
- font-size: var(--font16Size);
- color: var(--f85Color);
- }
- .other_3 {
- flex-grow: 1;
- margin: 0 0 0 2vw;
- font-size: var(--font12Size);
- }
- text {
- padding: 0 1vw 0 0;
- font-size: var(--font20Szie);
- }
- }
- }
- }
- .other {
- display: flex;
- justify-content: space-between;
- background-color: var(--mainColor);
- border-bottom: 0.1vw solid var(--fcColor);
- margin: 0 0 2vw 0;
- width: 96vw;
- padding: 2vw;
- .other_1 {
- font-size: var(--font16Size);
- color: var(--f85Color);
- }
- .other_3 {
- flex-grow: 1;
- margin: 0 0 0 2vw;
- font-size: var(--font12Size);
- }
- text {
- padding: 0 1vw 0 0;
- font-size: var(--font20Szie);
- }
- }
- }
- }
- .two {
- display: flex;
- justify-content: space-between;
- border-top: 0.1vw solid var(--fcColor);
- .two_1 {
- display: flex;
- align-items: center;
- padding: 0 2vw;
- font-size: var(--font16Size);
- view:last-child {
- margin: 0 0 0 2vw;
- color: var(--fFB1Color);
- font-weight: bold;
- }
- }
- .two_2 {
- padding: 3vw 4vw;
- color: var(--mainColor);
- font-size: var(--font16Size);
- background-color: #6A5ACD;
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- }
- }
- .popup {
- display: flex;
- flex-direction: column;
- height: 100vw;
- overflow-x: hidden;
- background-color: var(--f5Color);
- padding: 2vw;
- .list {
- .one {
- display: flex;
- justify-content: space-between;
- margin: 2vw 0 0 0;
- padding: 2vw;
- background-color: var(--mainColor);
- .name {
- font-size: var(--font16Size);
- }
- .address {
- font-size: var(--font14Size);
- }
- .iconfont {
- line-height: 15vw;
- font-size: var(--font20Szie);
- }
- }
- .two {
- display: flex;
- justify-content: space-between;
- border-top: 0.1vw solid var(--fcColor);
- padding: 2vw;
- background-color: var(--mainColor);
- font-size: var(--font14Size);
- .text {
- margin: 0 2vw 0 0;
- border: 0.1vw solid var(--fFB1Color);
- padding: 1vw;
- font-size: var(--font12Size);
- border-radius: 2vw;
- color: var(--fFB1Color);
- }
- }
- }
- }
- </style>
|