Compare commits
28 Commits
d64127c11c
...
25517afb79
Author | SHA1 | Date |
---|---|---|
zmj | 25517afb79 | |
zmj | 89cd6cadb2 | |
zmj | 86b5969b11 | |
zmj | eb3b34ed42 | |
zmj | f9e9d0607e | |
zmj | d1a2593c86 | |
zmj | e4dcded2cf | |
zmj | 99a68f036b | |
zmj | d6c715bdd3 | |
zmj | 45b51b0a11 | |
zmj | 317ad7c192 | |
zmj | 03657673fb | |
zmj | b7af7ef629 | |
zmj | 183f272098 | |
zmj | a0d5fef974 | |
zmj | f1430c9bc6 | |
zmj | 1d7cf37dd7 | |
zmj | 0a97756fe6 | |
zmj | 754bac1994 | |
zmj | e5d13a791f | |
zmj | 002937f5a2 | |
zmj | 6605fe5571 | |
zmj | b8aaa100b4 | |
zmj | ea9e6ae292 | |
zmj | 1e52c22acd | |
zmj | edb5d70e9a | |
zmj | 9086ccd76f | |
zmj | 57fa7980cf |
|
@ -30,3 +30,7 @@ export const getMassageCode = (data) => {
|
|||
export const setPayPassword = (data) => {
|
||||
return request.post('/user/user/set_payPassword', data);
|
||||
}
|
||||
|
||||
export const getFundList = (data) => {
|
||||
return request.get('/user/user/fundList', data);
|
||||
}
|
|
@ -99,6 +99,10 @@ export const vipRechargeApi = (data) => {
|
|||
return request.post('/store/store/recharge', data);
|
||||
}
|
||||
|
||||
export const reVipRechargeApi = (data) => {
|
||||
return request.post('/store/store/again_recharge', data);
|
||||
}
|
||||
|
||||
export const rechargeCountApi = (data) => {
|
||||
return request.get('/store/store/recharge_count', data);
|
||||
}
|
||||
|
@ -138,3 +142,7 @@ export const getCreateLists = (data) => {
|
|||
export const getloginSms = (data) => {
|
||||
return request.post('/user/user/login_sms', data);
|
||||
}
|
||||
|
||||
export const getReportingSms = (data) => {
|
||||
return request.post('/user/user/reporting_sms', data);
|
||||
}
|
|
@ -8,13 +8,19 @@
|
|||
<view>商品名称</view>
|
||||
<view>{{ datas.name || datas.goods_name || datas.store_name }}</view>
|
||||
</view>
|
||||
<view class="row" v-if="datas.store_info">
|
||||
<view>商品规格</view>
|
||||
<view>{{ datas.store_info}}</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view>商品单位</view>
|
||||
<view>{{ datas.unit_name }}</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view>商品价格</view>
|
||||
<view>¥ {{ datas.price || datas.sell }} / {{ datas.unit_name }}</view>
|
||||
<view>¥ {{priceKey.off_activity==1? datas[priceKey.price]: datas[priceKey.op_price] }} /
|
||||
{{ datas.unit_name }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="row" v-if="datas.batch > 0">
|
||||
<view>起批量</view>
|
||||
|
@ -28,22 +34,16 @@
|
|||
</view>
|
||||
<view style="color: #F55726;" v-else>¥ {{ subtotal }}</view>
|
||||
</view>
|
||||
<view v-if="datas.is_bulk" class="row">
|
||||
<view v-if="datas.is_bulk" class="row" style="height: 100rpx;">
|
||||
<view>购买重量<text style="color: #F55726;">*</text></view>
|
||||
<view style="flex: 1;">
|
||||
<up-input v-model="datas.cart_num" :cursorSpacing='120' type="digit" border="none"
|
||||
placeholder="请输入购买重量" inputAlign="right"></up-input>
|
||||
<view style="justify-content: end;">
|
||||
<up-number-box v-model="datas.cart_num"></up-number-box>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="row">
|
||||
<view v-else class="row" style="height: 100rpx;">
|
||||
<view>购买数量<text style="color: #F55726;">*</text></view>
|
||||
<view style="flex: 1;">
|
||||
<up-input ref='foucs1' v-model="datas.cart_num" :cursorSpacing='120' type="digit" border="none"
|
||||
placeholder="请输入购买数量" inputAlign="right">
|
||||
<template #suffix>
|
||||
<span style="color: #20b128;">{{ datas.unit_name }}</span>
|
||||
</template>
|
||||
</up-input>
|
||||
<view style="justify-content: end;">
|
||||
<up-number-box v-model="datas.cart_num"></up-number-box>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row" style="padding-top: 30px;padding-bottom: 30rpx;">
|
||||
|
@ -80,13 +80,22 @@
|
|||
},
|
||||
})
|
||||
|
||||
|
||||
let priceKey = ref({})
|
||||
if (uni.getStorageSync('PRICE_KEY')) {
|
||||
priceKey.value = JSON.parse(uni.getStorageSync('PRICE_KEY'));
|
||||
} else {
|
||||
priceKey.value = {};
|
||||
}
|
||||
|
||||
|
||||
const datas = ref({
|
||||
cart_num: ''
|
||||
});
|
||||
const setData = (e) => {
|
||||
datas.value = e;
|
||||
if (Number(e.batch) > 0) datas.value.cart_num = e.batch;
|
||||
else datas.value.cart_num = '';
|
||||
else datas.value.cart_num = 1;
|
||||
|
||||
}
|
||||
|
||||
|
@ -107,13 +116,16 @@
|
|||
}
|
||||
|
||||
const subtotal = computed(() => {
|
||||
let num = +datas.value.cart_num || 0;
|
||||
let sell = +datas.value.sell || +datas.value.price;
|
||||
let num = +datas.value.cart_num || 1;
|
||||
let sell = +datas.value[priceKey.value.off_activity == 1 ? priceKey.value.price : priceKey.value.op_price];
|
||||
return Number(num * sell * 100 / 100).toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
defineExpose({
|
||||
setData,
|
||||
// founcsFn
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
let BASE_URL
|
||||
let WSS_URL
|
||||
import store from "@/store/user.js"
|
||||
// 环境
|
||||
// let env = "dev"
|
||||
|
@ -7,13 +8,18 @@ let env = "prod"
|
|||
|
||||
switch (env) {
|
||||
case 'dev':
|
||||
BASE_URL = 'https://test-multi-store.lihaink.cn';
|
||||
// BASE_URL = 'https://test-multi-store.lihaink.cn';
|
||||
// WSS_URL = 'wss://test-multi-store.lihaink.cn/pull'
|
||||
BASE_URL = 'https://ceshi-multi-store.lihaink.cn';
|
||||
WSS_URL = 'wss://ceshi-multi-store.lihaink.cn/pull'
|
||||
break;
|
||||
case 'liu':
|
||||
BASE_URL = 'http://192.168.1.201:8545';
|
||||
BASE_URL = 'https://ceshi-multi-store.lihaink.cn';
|
||||
WSS_URL = 'wss://ceshi-multi-store.lihaink.cn/pull'
|
||||
break;
|
||||
default:
|
||||
BASE_URL = 'https://multi-store.lihaink.cn';
|
||||
WSS_URL = 'wss://multi-store.lihaink.cn/pull'
|
||||
}
|
||||
|
||||
let HTTP_REQUEST_URL
|
||||
|
@ -21,6 +27,7 @@ let HEADER
|
|||
|
||||
let config = {
|
||||
HTTP_REQUEST_URL: BASE_URL,
|
||||
WSS_URL: WSS_URL,
|
||||
HEADER: {
|
||||
'content-type': 'application/json',
|
||||
//#ifdef MP
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
<template>
|
||||
<up-sticky bgColor="#fff">
|
||||
<up-tabs :list="tabsLst" :itemStyle="{width:'33vw',paddingBottom:'20rpx'}" lineColor='#50C758' :current='mark'
|
||||
@change="tabsChange"></up-tabs>
|
||||
</up-sticky>
|
||||
<block v-if="lists.length>0">
|
||||
<view class="content" v-if='type==1||type==2'>
|
||||
<view class="li" v-for="(item,index) in lists" :key="index">
|
||||
<view class="li-top">
|
||||
<text>{{item.title}}</text>
|
||||
<text style="font-weight: bold;" :style="{color:item.type=='in'?'#50C758':'red'
|
||||
}">{{ item.type=='in'?'+':'-' }}{{item.amount}}</text>
|
||||
</view>
|
||||
<view class="li-top" style="margin-bottom: 0;">
|
||||
<text style="font-size: 24rpx;color: grey;">{{item.create_time}}</text>
|
||||
<text style="font-size: 24rpx;color: grey;">余额 {{item.before_balance}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content" v-if='type==3'>
|
||||
<view class="li" v-for="(item,index) in lists" :key="index">
|
||||
<view class="li-top">
|
||||
<text>{{item.title}}</text>
|
||||
<text style="font-weight: bold;" :style="{color:!item.financial_pm?'#50C758':'red'
|
||||
}">{{ !item.financial_pm?'+':'-' }}{{item.number}}</text>
|
||||
</view>
|
||||
<view class="li-top" style="margin-bottom: 0;">
|
||||
<text style="font-size: 24rpx;color: grey;">{{item.create_time}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content" v-if='type==4'>
|
||||
<view class="li" v-for="(item,index) in lists" :key="index">
|
||||
<view class="li-top">
|
||||
<text>{{item.order_sn}}</text>
|
||||
<text style="font-weight: bold;" :style="{color:!item.status?'#50C758':'red'
|
||||
}">{{ !item.status?'+':'-' }}{{item.number}}</text>
|
||||
</view>
|
||||
<view class="li-top" style="margin-bottom: 0;">
|
||||
<text style="font-size: 24rpx;color: grey;">{{item.create_time}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<up-empty v-else mode="history" style="margin-top: 20vh;" text='没有更多内容了'>
|
||||
</up-empty>
|
||||
|
||||
<view style="height: 50rpx;">
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref,
|
||||
reactive
|
||||
} from "vue"
|
||||
import {
|
||||
onLoad,
|
||||
onPullDownRefresh
|
||||
} from "@dcloudio/uni-app"
|
||||
import {
|
||||
getFundList
|
||||
} from "@/api/address.js"
|
||||
|
||||
const navLists = ['', '采购款明细', '余额明细', '礼品券明细', '返还金明细']
|
||||
const tabsLst = reactive([{
|
||||
name: '全部'
|
||||
},
|
||||
{
|
||||
name: '收入'
|
||||
},
|
||||
{
|
||||
name: '支出'
|
||||
},
|
||||
]);
|
||||
|
||||
const mark = ref(0)
|
||||
const tabsChange = (e) => {
|
||||
mark.value = e.index
|
||||
getLists()
|
||||
}
|
||||
|
||||
const lists = ref([])
|
||||
let type = ref('')
|
||||
const getLists = async (isPullDown = false) => {
|
||||
let res = await getFundList({
|
||||
type: type.value,
|
||||
mark: mark.value || ''
|
||||
})
|
||||
lists.value = res.data.lists
|
||||
if (isPullDown) uni.stopPullDownRefresh()
|
||||
|
||||
}
|
||||
|
||||
onLoad((opt) => {
|
||||
type.value = opt.type
|
||||
uni.setNavigationBarTitle({
|
||||
title: navLists[type.value]
|
||||
})
|
||||
getLists()
|
||||
})
|
||||
|
||||
onPullDownRefresh(() => {
|
||||
getLists(true)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.content {
|
||||
background-color: white;
|
||||
width: 690rpx;
|
||||
padding: 20rpx;
|
||||
margin: 0 auto;
|
||||
box-sizing: border-box;
|
||||
margin: 0 auto;
|
||||
margin-top: 30rpx;
|
||||
border-radius: 20rpx;
|
||||
margin-bottom: 100rpx;
|
||||
|
||||
.li {
|
||||
margin-top: 20rpx;
|
||||
border-bottom: 1px solid #EDF2FA;
|
||||
padding-bottom: 20rpx;
|
||||
|
||||
.li-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
File diff suppressed because it is too large
Load Diff
13
pages.json
13
pages.json
|
@ -52,8 +52,8 @@
|
|||
"path": "pages/my/my",
|
||||
"style": {
|
||||
"navigationBarTitleText": "个人中心",
|
||||
"enablePullDownRefresh": false,
|
||||
"navigationStyle": "custom"
|
||||
"enablePullDownRefresh": true,
|
||||
"navigationBarBackgroundColor": "#D3FDCA"
|
||||
}
|
||||
}, {
|
||||
"path": "pages/charge/charge_record",
|
||||
|
@ -234,9 +234,14 @@
|
|||
"navigationBarTitleText": "会员报备",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "balanceDetail/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "余额明细",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
@ -34,9 +34,12 @@
|
|||
<view class="title">
|
||||
<view class="name u-line-2">{{item.goods_name}}</view>
|
||||
<view class="tip u-line-1">{{item.unit_name}}</view>
|
||||
<view v-if="priceKey.off_activity==1" class="tip u-line-1">原价:<text
|
||||
style="text-decoration: line-through;">¥{{item[priceKey.op_price]}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="price-btn">
|
||||
<view class="price">¥{{item.sell}}</view>
|
||||
<view class="price">¥{{item[priceKey.price]}}</view>
|
||||
<view class="btn">
|
||||
<view class="num">{{item.cart_num}}</view>
|
||||
<u--icon name="plus-circle-fill" size="20" color="#20b128"></u--icon>
|
||||
|
@ -109,14 +112,11 @@
|
|||
</view>
|
||||
</view>
|
||||
<view style="width: 200rpx;">
|
||||
<up-button color="#20b128" shape="circle" :disabled="!checkAll || c_price0<500 "
|
||||
@click="settleAccounts">
|
||||
<view class="" v-if='c_price0>=500'>
|
||||
<up-button color="#20b128" shape="circle" @click="settleAccounts">
|
||||
<view class="">
|
||||
去结算<text v-if="checkAll">({{checkAll}})</text>
|
||||
</view>
|
||||
<view class="" v-else>
|
||||
¥500起订
|
||||
</view>
|
||||
|
||||
</up-button>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -132,7 +132,8 @@
|
|||
|
||||
<script setup>
|
||||
import {
|
||||
onShow
|
||||
onShow,
|
||||
onLoad
|
||||
} from "@dcloudio/uni-app"
|
||||
import {
|
||||
computed,
|
||||
|
@ -206,21 +207,21 @@
|
|||
|
||||
// 购物车相关
|
||||
const addCart = (id, cart_num) => { //加入购物车
|
||||
if (uni.getStorageSync('STORE_INFO').length) {
|
||||
let data = JSON.parse(uni.getStorageSync('STORE_INFO'))
|
||||
let STORE_INFO = {};
|
||||
for (let key in data) {
|
||||
STORE_INFO[key] = data[key]
|
||||
}
|
||||
cartCreateApi({
|
||||
cart_num: +cart_num,
|
||||
product_id: id,
|
||||
store_id: STORE_INFO.id
|
||||
// store_id:
|
||||
}).then(res => {
|
||||
getcartList();
|
||||
})
|
||||
}
|
||||
if (uni.getStorageSync('STORE_INFO').length) {
|
||||
let data = JSON.parse(uni.getStorageSync('STORE_INFO'))
|
||||
let STORE_INFO = {};
|
||||
for (let key in data) {
|
||||
STORE_INFO[key] = data[key]
|
||||
}
|
||||
cartCreateApi({
|
||||
cart_num: +cart_num,
|
||||
product_id: id,
|
||||
store_id: STORE_INFO.id
|
||||
// store_id:
|
||||
}).then(res => {
|
||||
getcartList();
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
const isAdmin = ref(false); //是否管理
|
||||
|
@ -253,15 +254,19 @@
|
|||
} else {
|
||||
checkAll.value = 0
|
||||
}
|
||||
res.data.lists = res.data.lists.map(item => {
|
||||
if(!item.price) item.price = item.sell; // 兼容旧数据,新数据已经添加了price字段
|
||||
return item;
|
||||
})
|
||||
res.data.lists = res.data.lists.map(item => {
|
||||
if (!item.price) item.price = item.sell; // 兼容旧数据,新数据已经添加了price字段
|
||||
return item;
|
||||
})
|
||||
cartList.value = res.data.lists;
|
||||
cartInfo.value = {
|
||||
total_price: res.data?.extend.total_price || '0.00',
|
||||
pay_price: res.data?.extend.pay_price || '0.00',
|
||||
count: res.data?.count || 0
|
||||
}
|
||||
|
||||
|
||||
console.log(cartInfo.value)
|
||||
setTimeout(() => {
|
||||
triggered.value = false;
|
||||
}, 300)
|
||||
|
@ -269,11 +274,11 @@
|
|||
}
|
||||
|
||||
const c_price0 = computed(() => {
|
||||
let price = cartInfo.value.total_price + '';
|
||||
let price = cartInfo.value.pay_price + '';
|
||||
return price.split('.')[0] || '0';
|
||||
})
|
||||
const c_price1 = computed(() => {
|
||||
let price = cartInfo.value.total_price + '';
|
||||
let price = cartInfo.value.pay_price + '';
|
||||
return price.split('.')[1] || '00';
|
||||
})
|
||||
|
||||
|
@ -281,15 +286,18 @@
|
|||
let checkAll = ref(0)
|
||||
const checkItem = (item, type) => {
|
||||
item.check = type;
|
||||
let price = Number(cartInfo.value.total_price);
|
||||
let price = Number(cartInfo.value.pay_price);
|
||||
if (type) {
|
||||
price += item.sell * item.cart_num;
|
||||
price += (priceKey.value.off_activity == 1 ? item[priceKey.value.price] : item[priceKey.value.op_price]) *
|
||||
item
|
||||
.cart_num;
|
||||
checkAll.value++;
|
||||
} else {
|
||||
price -= item.sell * item.cart_num;
|
||||
price -= (priceKey.value.off_activity == 1 ? item[priceKey.value.price] : item[priceKey.value.op_price]) *
|
||||
item.cart_num;
|
||||
checkAll.value--;
|
||||
}
|
||||
cartInfo.value.total_price = price.toFixed(2);
|
||||
cartInfo.value.pay_price = price.toFixed(2);
|
||||
}
|
||||
const changeAll = (flag = false) => {
|
||||
let count = 0;
|
||||
|
@ -332,6 +340,15 @@
|
|||
onShow(() => {
|
||||
getcartList();
|
||||
})
|
||||
let priceKey = ref({})
|
||||
onLoad(() => {
|
||||
if (uni.getStorageSync('PRICE_KEY')) {
|
||||
priceKey.value = JSON.parse(uni.getStorageSync('PRICE_KEY'));
|
||||
} else {
|
||||
priceKey.value = {};
|
||||
}
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
@ -406,8 +423,8 @@
|
|||
}
|
||||
|
||||
.shop-img {
|
||||
height: 120rpx;
|
||||
width: 120rpx;
|
||||
height: 164rpx;
|
||||
width: 164rpx;
|
||||
margin-right: 20rpx;
|
||||
border-radius: 14rpx;
|
||||
}
|
||||
|
|
|
@ -39,13 +39,12 @@
|
|||
:style="{ height: btns.height + 'px', top: btns.top + 'px', left: (btns.left - 40) + 'px' }">
|
||||
<up-button icon="share-square" openType="share" plain size="large" loadingSize="100" />
|
||||
</view>
|
||||
|
||||
<view class="navbar">
|
||||
<view style="width: 400rpx;">
|
||||
<up-search placeholder="请输入商品" @search="searchKeyword" @clear="searchKeyword" v-model="keyword"
|
||||
:showAction="false"></up-search>
|
||||
</view>
|
||||
<view class="nav-item" @click="navTo('/pages/cart/cart')">
|
||||
<view class="nav-item" @click="navTo(`/pages/cart/cart`)">
|
||||
<image src="@/static/tab/ba.png"></image>
|
||||
<text>购物车</text>
|
||||
</view>
|
||||
|
@ -117,8 +116,17 @@
|
|||
<view class="order-by">
|
||||
<view class="item" :class="{ 'order-active': where.order == '' }" @click="changeOrder('')">综合
|
||||
</view>
|
||||
<view class="item" :class="{ 'order-active': where.order == 'desc' || where.order == 'asc' }"
|
||||
@click="changeOrder(where.order == 'asc' ? 'desc' : 'asc')">价格</view>
|
||||
<view class="item" style="display: flex;align-items: center;"
|
||||
:class="{ 'order-active': where.order == 'desc' || where.order == 'asc' }"
|
||||
@click="changeOrder(where.order == 'asc' ? 'desc' : 'asc')">
|
||||
价格
|
||||
<view style="color: black;">
|
||||
<up-icon name="arrow-up-fill" :color="where.order=='asc'?'#20b128':'' "
|
||||
size="8"></up-icon>
|
||||
<up-icon name="arrow-down-fill" :color="where.order=='desc'?'#20b128':'' "
|
||||
size="8"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" :class="{ 'order-active': where.order == 'sales' }"
|
||||
@click="changeOrder('sales')">销量
|
||||
</view>
|
||||
|
@ -145,33 +153,54 @@
|
|||
<view class="shop-img"
|
||||
:style="{ backgroundImage: `url(${item.image}?x-oss-process=image/format,webp)` }">
|
||||
</view>
|
||||
|
||||
<view class="shop-content">
|
||||
<view class="title">
|
||||
<view class="name u-line-2">{{ item.store_name }}</view>
|
||||
<view class="tip u-line-1">
|
||||
<text>{{ item.spec }}</text>
|
||||
<view class="goods-name" style="font-size: 28rpx;color: #060606;">
|
||||
{{ item.store_name }}
|
||||
</view>
|
||||
<view class="shop-content-li" v-if="priceKey.off_activity==1">
|
||||
<view class="shop-content-li-l" style="color: #FC452F;">
|
||||
活动价
|
||||
</view>
|
||||
<view class="shop-content-li-r" style="color:#FC452F ;">¥<text
|
||||
style="font-size: 30rpx;">{{item[priceKey.price]}}</text>/{{ item.unit_name }}
|
||||
</view>
|
||||
<view class="tag">
|
||||
<view class="icon" />
|
||||
赠10%品牌礼品
|
||||
</view>
|
||||
</view>
|
||||
<view style="display: flex;" v-if='item.batch > 0'>
|
||||
<view style="color: red;">起批量: {{ item.batch }}{{ item.unit_name }}起卖</view>
|
||||
<view class="shop-content-li" style="color: #999999;" v-if="priceKey.off_activity==1">
|
||||
<view class="shop-content-li-l">原价</view>
|
||||
<view class="shop-content-li-r line-through">¥{{item[priceKey.op_price]}}</view>
|
||||
</view>
|
||||
<!-- <view style="display: flex;align-items: center;" v-if='userStore?.userInfo?.user_ship == 1'>
|
||||
<text class='price' style="font-size: 24rpx;">会员价¥</text>
|
||||
<text class="price" style="margin-right: 10rpx;">{{ item.vip_price }}
|
||||
</text>
|
||||
<text class='price' style="font-size: 24rpx;">/{{ item.unit_name }}</text>
|
||||
</view> -->
|
||||
<view class="price-btn">
|
||||
<!-- <view class="price" style="font-size: 24rpx;"
|
||||
v-if='userStore?.userInfo?.user_ship == 1'>
|
||||
¥{{ item.price }}/{{ item.unit_name }}
|
||||
</view> -->
|
||||
<view class="price">
|
||||
¥{{ item.price }}/{{ item.unit_name }}
|
||||
|
||||
<view class="shop-content-li" v-else>
|
||||
<view class="shop-content-li-l">售价</view>
|
||||
<view class="shop-content-li-r" style="color:#FC452F ;">¥<text
|
||||
style="font-size: 28rpx;">{{item[priceKey.op_price]}}</text>
|
||||
</view>
|
||||
<view class="btn">
|
||||
</view>
|
||||
|
||||
<view class="shop-content-li" style="justify-content: space-between;"
|
||||
v-if="item.store_info">
|
||||
<view style="display: flex;">
|
||||
<view class="shop-content-li-l">规格</view>
|
||||
<view class="shop-content-li-r">{{ item.store_info }}</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="shop-content-li" style="justify-content: space-between;" v-if="item.batch">
|
||||
<view style="display: flex;">
|
||||
<view class="shop-content-li-l">起批量</view>
|
||||
<view class="shop-content-li-r">{{ item.batch }}{{ item.unit_name }}起卖</view>
|
||||
</view>
|
||||
<!-- <view class="btn">
|
||||
<u--icon name="plus-circle-fill" size="20" color="#20b128"></u--icon>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="shopconetent-btn">
|
||||
<u--icon name="plus-circle-fill" size="20" color="#20b128"></u--icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -184,28 +213,44 @@
|
|||
<view class="row">
|
||||
<view>合计</view>
|
||||
<view class="price" v-if='cartInfo.pay_price<=0||userStore?.userInfo?.user_ship !=4'>¥<text
|
||||
style="font-size: 36rpx;">{{ cartInfo.total_price }}</text></view>
|
||||
<view class="price" v-else>¥<text style="font-size: 30rpx;">{{ cartInfo.total_price }}</text></view>
|
||||
<view class="price" v-if="cartInfo.pay_price>0 &&userStore?.userInfo?.user_ship == 4"><text
|
||||
style="font-size: 36rpx;">优惠后
|
||||
{{ cartInfo.pay_price }}</text></view>
|
||||
style="font-size: 36rpx;">{{ cartInfo.pay_price }}</text></view>
|
||||
</view>
|
||||
<view style="font-size: 22rpx;text-indent: 3em;color: #F55726;"
|
||||
v-if="cartInfo.msg&&cartInfo.total_price>0 ">
|
||||
{{cartInfo.msg }}
|
||||
</view>
|
||||
<!-- <view class="row">
|
||||
<view style="color: #777;">原价 ¥50.00</view>
|
||||
<view class="price">优惠 ¥0.00</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="btn">
|
||||
<up-button color="#20b128" :disabled="cartInfo.total_price < 500" @click="settleAccounts">
|
||||
{{ cartInfo.total_price < 500 ? "¥500起订" : "结算" }} </up-button>
|
||||
<up-button color="#20b128" :disabled="cartInfo.pay_price<=0" @click="settleAccounts"> 结算</up-button>
|
||||
</view>
|
||||
<view class="cart" @click="navTo('/pages/cart/cart')">
|
||||
<view class="cart" @click="navTo(`/pages/cart/cart`)">
|
||||
<image src="@/static/icon/cart.png"></image>
|
||||
<view class="badge">{{ cartInfo.count }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<goodPopup ref="goodRef" :show="showGoodPopup" @close="showGoodPopup = false" @change="changeGood" />
|
||||
|
||||
<u-overlay :show="showOverlay" @click="showOverlay = false">
|
||||
<view class="warp">
|
||||
<view class="rect" @tap.stop>
|
||||
<view class="rect-tit">
|
||||
温馨提示
|
||||
</view>
|
||||
<view class="rect-contetn">
|
||||
只需再购买 {{500- cartInfo.pay_price}} 元,就能拥有10%的品牌礼品券,若错过此次机会则无礼品券
|
||||
</view>
|
||||
<view class="rect-btn">
|
||||
<view style="width: 236rpx;">
|
||||
<up-button @click="abandActive">放弃优惠</up-button>
|
||||
</view>
|
||||
<view style="width: 236rpx;">
|
||||
<up-button color="#20b128" @click="showOverlay=false">继续采购</up-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-overlay>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
@ -232,7 +277,8 @@
|
|||
import {
|
||||
productLogApi,
|
||||
userInfoApi,
|
||||
getStoreInfo
|
||||
getStoreInfo,
|
||||
loginUpdateUserApi
|
||||
} from "@/api/user.js";
|
||||
import viewPopup from "@/components/viewPopup.vue"
|
||||
import goodPopup from "@/components/goodPopup.vue"
|
||||
|
@ -247,8 +293,16 @@
|
|||
import useUserStore from "@/store/user";
|
||||
const userStore = useUserStore();
|
||||
const STORE_INFO = reactive({
|
||||
id: 23,
|
||||
store_name: "农(特)产品直营店"
|
||||
id: '',
|
||||
store_name: ""
|
||||
})
|
||||
|
||||
|
||||
|
||||
const priceKey = reactive({
|
||||
off_activity: "",
|
||||
op_price: "",
|
||||
price: ""
|
||||
})
|
||||
|
||||
const getStoreInfoFn = () => {
|
||||
|
@ -264,9 +318,11 @@
|
|||
for (let key in data) {
|
||||
STORE_INFO[key] = data[key]
|
||||
}
|
||||
getgoodClassList(0);
|
||||
getGoodList();
|
||||
|
||||
})
|
||||
}
|
||||
getStoreInfoFn()
|
||||
|
||||
|
||||
// 分享给好友
|
||||
|
@ -360,6 +416,19 @@
|
|||
}
|
||||
|
||||
const changeOrder = (order) => {
|
||||
switch (order) {
|
||||
case 'asc':
|
||||
where.value.field = 'price'
|
||||
break;
|
||||
case 'desc':
|
||||
where.value.field = 'price'
|
||||
break;
|
||||
case 'sales':
|
||||
where.value.field = 'sales'
|
||||
break;
|
||||
default:
|
||||
where.value.field = ''
|
||||
}
|
||||
where.value.order = order;
|
||||
getGoodList();
|
||||
}
|
||||
|
@ -370,13 +439,14 @@
|
|||
name: '',
|
||||
order: '',
|
||||
store_name: '',
|
||||
// store_id: 23
|
||||
store_id: 4
|
||||
store_id: '',
|
||||
field: "",
|
||||
})
|
||||
|
||||
const loading = ref(true);
|
||||
const goodList = ref([]);
|
||||
const getGoodList = (loadmore = false) => {
|
||||
where.value.store_id = STORE_INFO.id; // 店铺id
|
||||
loading.value = true;
|
||||
let class_id = rightActive.value || leftActive.value || topActive.value || '';
|
||||
let class_all = '';
|
||||
|
@ -387,21 +457,19 @@
|
|||
if (class_all) class_id = ""; //只能带其中一个
|
||||
if (loadmore) where.value.page_no++;
|
||||
else where.value.page_no = 1;
|
||||
// where.value.store_id = 23
|
||||
where.value.store_id = 4
|
||||
goodListApi({
|
||||
...where.value,
|
||||
class_all: class_all,
|
||||
class: class_id,
|
||||
cate_id: class_id,
|
||||
}).then(res => {
|
||||
for (let key in res.data.extend) {
|
||||
priceKey[key] = res.data.extend[key]
|
||||
}
|
||||
uni.setStorageSync("PRICE_KEY", JSON.stringify(priceKey))
|
||||
console.log(priceKey)
|
||||
if (loadmore) goodList.value.push(...res.data.lists);
|
||||
else goodList.value = res.data.lists;
|
||||
// 补充店铺信息
|
||||
// if (!STORE_INFO.store_name || !STORE_INFO.detailed_address) {
|
||||
// STORE_INFO.store_name = res.data.store.name;
|
||||
// STORE_INFO.value.detailed_address = res.data.store.detailed_address;
|
||||
// }
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -423,9 +491,7 @@
|
|||
page_no: page_no,
|
||||
page_size: 30,
|
||||
level: three,
|
||||
// store_id: STORE_INFO.id // 店铺id,用于获取店铺分类列表,如果为空则获取全部分类列表,否则获取店铺分类列表。
|
||||
// store_id: 23 // 店铺id,用于获取店铺分类列表,如果为空则获取全部分类列表,否则获取店铺分类列表。
|
||||
store_id: 4 // 店铺id,用于获取店铺分类列表,如果为空则获取全部分类列表,否则获取店铺分类列表。
|
||||
store_id: STORE_INFO.id // 店铺id,用于获取店铺分类列表,如果为空则获取全部分类列表,否则获取店铺分类列表。
|
||||
}).then(res => {
|
||||
if (pid == 0) { // 加载一级分类时设置全部分类
|
||||
if (!res.data?.lists?.length) return;
|
||||
|
@ -527,10 +593,7 @@
|
|||
const openGoodPopup = (item) => { // 打开数量/重量弹窗
|
||||
goodData.value = item;
|
||||
goodRef.value.setData(item);
|
||||
// goodRef.value.founcsFn();
|
||||
showGoodPopup.value = true;
|
||||
|
||||
|
||||
//统计商品的访问记录
|
||||
productLogApi({
|
||||
product_id: item.product_id,
|
||||
|
@ -558,8 +621,21 @@
|
|||
|
||||
addCart(data.product_id, data.cart_num);
|
||||
}
|
||||
|
||||
|
||||
// 结算
|
||||
const showOverlay = ref(false); // 遮罩层显示状态
|
||||
|
||||
const abandActive = () => {
|
||||
showOverlay.value = false
|
||||
uni.navigateTo({
|
||||
url: '/pagesOrder/settle/settle'
|
||||
})
|
||||
}
|
||||
|
||||
const settleAccounts = () => {
|
||||
|
||||
if (+cartInfo.value.pay_price < 500) return showOverlay.value = true;
|
||||
uni.navigateTo({
|
||||
url: '/pagesOrder/settle/settle'
|
||||
})
|
||||
|
@ -569,7 +645,8 @@
|
|||
const cartInfo = ref({
|
||||
total_price: '0.00',
|
||||
pay_price: 0,
|
||||
count: 0
|
||||
count: 0,
|
||||
msg: ''
|
||||
})
|
||||
const getCartList = (res) => {
|
||||
cartListApi({
|
||||
|
@ -579,6 +656,7 @@
|
|||
cartInfo.value = {
|
||||
total_price: res.data?.extend?.total_price || '0.00',
|
||||
pay_price: res.data?.extend?.pay_price || '0.00',
|
||||
msg: res.data?.extend?.msg || '',
|
||||
count: res.data?.count || 0
|
||||
}
|
||||
cartStore.setCartList(res.data?.lists.map(item => item.id))
|
||||
|
@ -609,13 +687,17 @@
|
|||
getShareInfo()
|
||||
|
||||
onLoad(async (opt) => {
|
||||
where.value.store_id = opt.id || STORE_INFO.id;
|
||||
// 店铺id
|
||||
if (opt.id) {
|
||||
where.value.store_id = (opt.id == 'undefined' ? STORE_INFO.id : opt.id);
|
||||
} else {
|
||||
where.value.store_id = STORE_INFO.id
|
||||
}
|
||||
// 店铺id
|
||||
if (opt.id && opt.id != 'undefined') {
|
||||
console.log(opt.id, opt.id != 'undefined', "进来了这里")
|
||||
where.value.store_id = opt.id;
|
||||
const info = await shopDetailApi({
|
||||
store_id: 4
|
||||
// store_id: 23
|
||||
store_id: where.value.store_id
|
||||
});
|
||||
// 分享参数至当前用户参数
|
||||
if (opt.spread_uid) {
|
||||
|
@ -625,8 +707,9 @@
|
|||
uni.setStorageSync('SHARE_INFO', shareInfo.value);
|
||||
}
|
||||
}
|
||||
getgoodClassList(0);
|
||||
getGoodList();
|
||||
|
||||
getStoreInfoFn()
|
||||
|
||||
// #ifndef H5
|
||||
// 胶囊布局信息
|
||||
btns.value = uni.getMenuButtonBoundingClientRect();
|
||||
|
@ -639,6 +722,10 @@
|
|||
userInfoApi().then(res => {
|
||||
const user = res.data;
|
||||
userStore.setUserInfo(user);
|
||||
if (!user.openid) loginUpdateUserApi({
|
||||
mobile: user.mobile
|
||||
})
|
||||
|
||||
if (user.is_staff == 1) {
|
||||
uni.reLaunch({
|
||||
url: "/multipleShop/verificationOrder/index"
|
||||
|
@ -702,11 +789,13 @@
|
|||
.badge {
|
||||
position: absolute;
|
||||
top: -10rpx;
|
||||
right: 0;
|
||||
right: 10rpx;
|
||||
background-color: #FF0000;
|
||||
color: #FFFFFF;
|
||||
padding: 0 8rpx;
|
||||
border-radius: 50rpx;
|
||||
text-align: center;
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
border-radius: 30rpx;
|
||||
font-size: 18rpx;
|
||||
}
|
||||
|
||||
|
@ -984,8 +1073,8 @@
|
|||
display: flex;
|
||||
|
||||
.shop-img {
|
||||
height: 120rpx;
|
||||
width: 120rpx;
|
||||
height: 164rpx;
|
||||
width: 164rpx;
|
||||
margin-right: 20rpx;
|
||||
border-radius: 14rpx;
|
||||
overflow: hidden;
|
||||
|
@ -997,40 +1086,54 @@
|
|||
width: 380rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
justify-content: space-around;
|
||||
position: relative;
|
||||
|
||||
.title {
|
||||
.name {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.tip {
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
margin: 2rpx 0;
|
||||
}
|
||||
}
|
||||
|
||||
.price {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #F55726;
|
||||
}
|
||||
|
||||
.price-btn {
|
||||
.shop-content-li {
|
||||
font-size: 22rpx;
|
||||
color: #333333;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
vertical-align: middle;
|
||||
|
||||
.btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.line-through {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.shop-content-li-l {
|
||||
font-size: 22rpx;
|
||||
width: 70rpx;
|
||||
text-align-last: justify;
|
||||
margin-right: 6rpx;
|
||||
|
||||
.num {
|
||||
width: 60rpx;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tag {
|
||||
font-size: 16rpx;
|
||||
color: #A17C3A;
|
||||
background-color: #F3E7C0;
|
||||
padding: 8rpx 4rpx;
|
||||
margin-left: 4rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
|
||||
.shopconetent-btn {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
// .icon {
|
||||
// background-image: url('https://lihai001.oss-cn-chengdu.aliyuncs.com/attach/3b653202406260957228679.png');
|
||||
// width: 17rpx;
|
||||
// height: 14rpx;
|
||||
// background-size: 100% 100%;
|
||||
// margin: 5rpx;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1102,4 +1205,41 @@
|
|||
margin: 0 0 20rpx 20rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.warp {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.rect {
|
||||
width: 630rpx;
|
||||
height: 440rpx;
|
||||
background-image: url('https://lihai001.oss-cn-chengdu.aliyuncs.com/attach/9c70c202406261048431851.png');
|
||||
background-size: 100% 100%;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
// padding: 30rpx;
|
||||
padding: 50rpx 32rpx;
|
||||
|
||||
.rect-tit {
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
color: #333333;
|
||||
margin-bottom: 60rpx;
|
||||
|
||||
}
|
||||
|
||||
.rect-contetn {
|
||||
font-size: 30rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.rect-btn {
|
||||
display: flex;
|
||||
margin-top: 50rpx;
|
||||
justify-content: space-around;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -120,6 +120,9 @@
|
|||
|
||||
// 微信公众号绑定
|
||||
const officialCode = () => {
|
||||
console.log("jinfas")
|
||||
return
|
||||
|
||||
uni.navigateTo({
|
||||
url: `/pages/code/code?id=${userStore.userInfo.id}`,
|
||||
success: () => {
|
||||
|
@ -168,7 +171,6 @@
|
|||
} else {
|
||||
userStore.setUserInfo(res.data);
|
||||
//再次登录 已有手机号 判断是否员工
|
||||
|
||||
//身份授权成功 核销人员
|
||||
if (res.data.is_staff == 1) {
|
||||
userStore.setUserInfo(res.data);
|
||||
|
@ -209,6 +211,7 @@
|
|||
}).then(res => {
|
||||
//手机号获取成功 可以本地缓存用户信息以及token
|
||||
userStore.setUserInfo(res.data);
|
||||
userStore.setToken(res.data.token);
|
||||
//身份授权成功 核销人员
|
||||
if (res.is_staff == 1) {
|
||||
userStore.setUserInfo(res.data);
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
userLoginApi,
|
||||
userInfoApi,
|
||||
getStoreInfo,
|
||||
getloginSms
|
||||
getloginSms,
|
||||
loginUpdateUserApi
|
||||
} from "@/api/user.js";
|
||||
import {
|
||||
ref,
|
||||
|
@ -94,10 +95,12 @@
|
|||
})
|
||||
uni.setStorageSync('token', res.data.token);
|
||||
userStore.setToken(res.data.token);
|
||||
console.log(res.data.token)
|
||||
userInfoApi().then(res => {
|
||||
const user = res.data;
|
||||
userStore.setUserInfo(user);
|
||||
if (!user.openid) loginUpdateUserApi({
|
||||
mobile: user.mobile
|
||||
})
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
}) // 存储token到本地存储中
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<style lang="scss">
|
||||
.rest {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
justify-content: space-between;
|
||||
margin: 20rpx;
|
||||
|
||||
.rest-item {
|
||||
|
@ -23,8 +23,8 @@
|
|||
</style>
|
||||
<template>
|
||||
<view>
|
||||
<up-navbar title="我的" :autoBack="true" bgColor="transparent" :fixed="true">
|
||||
</up-navbar>
|
||||
<!-- <up-navbar title="我的" :autoBack="true" bgColor="transparent" :fixed="true">
|
||||
</up-navbar> -->
|
||||
<view class="user-info">
|
||||
<image class="bg" src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/e3a7b202404261113002322.webp"
|
||||
mode="widthFix"></image>
|
||||
|
@ -40,36 +40,36 @@
|
|||
会员报备
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<view class="rest">
|
||||
<view class="rest-item">
|
||||
<view class="rest-item" @click="navgo('/pageQuota/balanceDetail/index?type=2')">
|
||||
<view class="rest-item-num">{{userInfo.now_money||"0.00"}}</view>
|
||||
<view class="rest-item-txt">余额</view>
|
||||
</view>
|
||||
<view class="rest-item">
|
||||
<view class="rest-item" @click="navgo('/pageQuota/balanceDetail/index?type=1')">
|
||||
<view class="rest-item-num">{{userInfo.purchase_funds||'0.00'}}</view>
|
||||
<view class="rest-item-txt">采购款</view>
|
||||
</view>
|
||||
<view class="rest-item">
|
||||
<view class="rest-item-num">{{userInfo.return_money||'0.00'}}</view>
|
||||
<!-- <view class="rest-item-num">{{"10000.00"}}</view> -->
|
||||
<view class="rest-item-txt">返还金</view>
|
||||
</view>
|
||||
|
||||
<!-- <view class="rest-item" @click="navgo('/pageQuota/balanceDetail/index?type=3')"> -->
|
||||
<view class="rest-item">
|
||||
<view class="rest-item-num">{{userInfo.integral ||"0.00"}}</view>
|
||||
<view class="rest-item-txt">礼品券</view>
|
||||
<view class="rest-item-num">{{userInfo.number ||"0.00"}}</view>
|
||||
<view class="rest-item-txt">冻结礼品券</view>
|
||||
</view>
|
||||
<!-- <view class="rest-item" @click="navgo('/pageQuota/balanceDetail/index?type=3')"> -->
|
||||
<view class="rest-item">
|
||||
<view class="rest-item-num">{{userInfo.GetNumber ||"0.00"}}</view>
|
||||
<view class="rest-item-txt">可用礼品券</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- <view class="gift">
|
||||
<view style="font-weight: bold;">
|
||||
供销经营礼包
|
||||
</view>
|
||||
<view class='gift-buy' @click="navgo('/pages/gift/index')">
|
||||
立即购买
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="order-info-box">
|
||||
<view class="order-info">
|
||||
<view class="info-head">我的订单</view>
|
||||
|
@ -131,13 +131,17 @@
|
|||
orderCountApi
|
||||
} from "@/api/order.js";
|
||||
import {
|
||||
onShow
|
||||
onShow,
|
||||
onPullDownRefresh
|
||||
} from "@dcloudio/uni-app"
|
||||
import {
|
||||
userInfoApi
|
||||
} from "@/api/user.js"
|
||||
|
||||
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
const userInfo = ref({});
|
||||
|
||||
const orderCount = ref({
|
||||
no_pay: 0,
|
||||
receiving: 0,
|
||||
|
@ -185,9 +189,18 @@
|
|||
}
|
||||
|
||||
onShow(() => {
|
||||
userInfo.value = userStore.userInfo;
|
||||
userInfoApi().then(res => {
|
||||
userInfo.value = res.data;
|
||||
})
|
||||
getOrderCount();
|
||||
})
|
||||
|
||||
onPullDownRefresh(() => {
|
||||
userInfoApi().then(res => {
|
||||
userInfo.value = res.data;
|
||||
uni.stopPullDownRefresh()
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
@ -195,7 +208,7 @@
|
|||
overflow: hidden;
|
||||
position: relative;
|
||||
width: 750rpx;
|
||||
height: 350rpx;
|
||||
height: 250rpx;
|
||||
|
||||
.bg {
|
||||
width: 100%;
|
||||
|
@ -209,7 +222,7 @@
|
|||
box-sizing: border-box;
|
||||
padding: 50rpx 0 50rpx 50rpx;
|
||||
position: absolute;
|
||||
top: 150rpx;
|
||||
top: 50rpx;
|
||||
left: 0;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<up-icon name="arrow-right-double" color="#20B128"></up-icon>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="all">共 {{datas.goods_count}} 件商品, 总金额 <text>¥{{datas.total_price}}</text> </view>
|
||||
<view class="all">共 {{datas.goods_count}} 件商品, 总金额 <text>¥{{datas.pay_price}}</text> </view>
|
||||
</view>
|
||||
<view v-if="datas.paid==0" class="item-btn">
|
||||
<view style="width: 80px;"><up-button size="small" plain color="#989898" shape="circle"
|
||||
|
|
|
@ -81,14 +81,17 @@
|
|||
const type = ref(1) // 1 输入密码 2 再次输入密码
|
||||
|
||||
const onKetDown = (e) => {
|
||||
uni.vibrateShort();
|
||||
if (type.value == 1) {
|
||||
form.password.length < 6 ?
|
||||
form.password += e :
|
||||
showKeyBorad.value = false
|
||||
if (form.password.length == 6) showKeyBorad.value = false;
|
||||
} else {
|
||||
form.rePassword.length < 6 ?
|
||||
form.rePassword += e :
|
||||
showKeyBorad.value = false
|
||||
if (form.rePassword.length == 6) showKeyBorad.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,10 +105,9 @@
|
|||
|
||||
// 键盘事件结束
|
||||
|
||||
|
||||
|
||||
const submit = async () => {
|
||||
if (!form.code) return uni.$u.toast('请输入验证码');
|
||||
if (form.password.length < 6) return uni.$u.toast('请输入6位数密码');
|
||||
if (form.password !== form.rePassword) return uni.$u.toast('两次密码不一致');
|
||||
await setPayPassword({
|
||||
...form
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
<view class="row">
|
||||
<view>商品总价 <text>共计{{ cartList.length }}款商品</text></view>
|
||||
<view>
|
||||
<text>¥</text>{{ c_price(orderInfo.total_price, 0) }}<text>.{{ c_price(orderInfo.total_price, 1) }}</text>
|
||||
<text>¥</text>{{ c_price(orderInfo.pay_price, 0) }}<text>.{{ c_price(orderInfo.pay_price, 1) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
|
@ -71,56 +71,12 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="row" v-if="userInfo.user_ship==1 ">
|
||||
<view>消费返利</view>
|
||||
<view>优惠返还</view>
|
||||
<view>
|
||||
<text>¥</text>{{ c_price(orderInfo.activity_price, 0) }}<text>.{{ c_price(orderInfo.activity_price, 1) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="m-card good-info">
|
||||
<view class="head-title">支付方式</view>
|
||||
<view class="row">
|
||||
<view class="icon-text">
|
||||
<up-icon name="weixin-circle-fill" color="#20b128" size="22"></up-icon>
|
||||
<text style="margin-left: 20rpx;font-size: 26rpx;">微信支付</text>
|
||||
</view>
|
||||
<view class="icon" @click="onChoosePaytype(7)">
|
||||
<image v-if="pay_type == 7" src="@/static/icon/check.png" />
|
||||
<image v-if="pay_type != 7 || pay_type == 3 || pay_type == 18 || !pay_type"
|
||||
src="@/static/icon/n-check.png" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="row"
|
||||
v-if="userInfo.user_ship == 4 || userInfo.user_ship == 5 || userInfo.user_ship == 6 || userInfo.user_ship == 1">
|
||||
<!-- <view class="row"> -->
|
||||
<view class="icon-text">
|
||||
<image src="@/static/icon/YEZF.png" style="width:40rpx;height: 40rpx;" />
|
||||
<text style="margin-left: 20rpx;font-size: 26rpx;">余额支付</text>
|
||||
<text style="margin-left: 20rpx;font-size: 22rpx;color: #FFB76D;">( 可用¥{{userInfo.now_money}}
|
||||
)</text>
|
||||
</view>
|
||||
<view class="icon" @click="onChoosePaytype(3)">
|
||||
<image v-if="pay_type == 3" src="@/static/icon/check.png" />
|
||||
<image v-if="pay_type != 3 || pay_type == 7 || pay_type == 18 || !pay_type"
|
||||
src="@/static/icon/n-check.png" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="row" v-if="userInfo.user_ship == 1">
|
||||
<view class="icon-text">
|
||||
<image src="@/static/icon/cgkzf.png" style="width:40rpx;height: 40rpx;" />
|
||||
<text style="margin-left: 20rpx;font-size: 26rpx;">采购款支付</text>
|
||||
<text style="margin-left: 20rpx;font-size: 22rpx;color: #1296DB;">( 可用¥{{userInfo.purchase_funds}}
|
||||
)</text>
|
||||
</view>
|
||||
<view class="icon" @click="onChoosePaytype(18)">
|
||||
<image v-if="pay_type == 18" src="@/static/icon/check.png" />
|
||||
<image v-if="pay_type != 18 || pay_type == 3 || pay_type == 7 || !pay_type"
|
||||
src="@/static/icon/n-check.png" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="m-card order-remark">
|
||||
<view class="head-title">
|
||||
|
@ -130,22 +86,77 @@
|
|||
<up-textarea style="background-color: #F6F6F6;" v-model="formData.remark" placeholder="暂无备注内容"
|
||||
:height="40"></up-textarea>
|
||||
</view>
|
||||
<view style="width: 100%;height: 200rpx;"></view>
|
||||
<view class="fiexd-btn-box" style="z-index: 999;">
|
||||
<view class="tips">
|
||||
<view style="margin-right: 20rpx;">共 {{ cartList.length }} 款</view>
|
||||
<view class="all">
|
||||
<text style="color: #000;">合计: </text>
|
||||
<text>¥</text>
|
||||
<block v-if="orderInfo.total_price">
|
||||
<text style="font-size: 32rpx;font-weight: bold;">{{ c_price(orderInfo.pay_price, 0) }}</text>
|
||||
<text>.{{ c_price(orderInfo.pay_price, 1) }}</text>
|
||||
</block>
|
||||
<view style="width: 100%;height: 500rpx;"></view>
|
||||
<view class="fiexd-bottom" style="z-index: 999;">
|
||||
<view class="pay-type-bottom">
|
||||
<view class=" good-info">
|
||||
<view class="head-title">支付方式</view>
|
||||
<view class="row">
|
||||
<view class="icon-text">
|
||||
<up-icon name="weixin-circle-fill" color="#20b128" size="22"></up-icon>
|
||||
<text style="margin-left: 20rpx;font-size: 26rpx;">微信支付</text>
|
||||
</view>
|
||||
<view class="icon" @click="onChoosePaytype(7)">
|
||||
<image v-if="pay_type == 7" src="@/static/icon/check.png" />
|
||||
<image v-if="pay_type != 7 || pay_type == 3 || pay_type == 18 || !pay_type"
|
||||
src="@/static/icon/n-check.png" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="row"
|
||||
v-if="userInfo.user_ship == 4 || userInfo.user_ship == 5 || userInfo.user_ship == 6 || userInfo.user_ship == 1">
|
||||
<!-- <view class="row"> -->
|
||||
<view class="icon-text">
|
||||
<image src="@/static/icon/YEZF.png" style="width:40rpx;height: 40rpx;" />
|
||||
<text style="margin-left: 20rpx;font-size: 26rpx;">余额支付</text>
|
||||
<text style="margin-left: 20rpx;font-size: 22rpx;color: #FFB76D;">(
|
||||
可用¥{{userInfo.now_money}}
|
||||
)</text>
|
||||
</view>
|
||||
<view class="icon" @click="onChoosePaytype(3)">
|
||||
<image v-if="pay_type == 3" src="@/static/icon/check.png" />
|
||||
<image v-if="pay_type != 3 || pay_type == 7 || pay_type == 18 || !pay_type"
|
||||
src="@/static/icon/n-check.png" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="row" v-if="userInfo.user_ship == 1">
|
||||
<view class="icon-text">
|
||||
<image src="@/static/icon/cgkzf.png" style="width:40rpx;height: 40rpx;" />
|
||||
<text style="margin-left: 20rpx;font-size: 26rpx;">采购款支付</text>
|
||||
<text style="margin-left: 20rpx;font-size: 22rpx;color: #1296DB;">(
|
||||
可用¥{{userInfo.purchase_funds}}
|
||||
)</text>
|
||||
</view>
|
||||
<view class="icon" @click="onChoosePaytype(18)">
|
||||
<image v-if="pay_type == 18" src="@/static/icon/check.png" />
|
||||
<image v-if="pay_type != 18 || pay_type == 3 || pay_type == 7 || !pay_type"
|
||||
src="@/static/icon/n-check.png" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view style="width: 200rpx;">
|
||||
<up-button color="#20B128" shape="circle" @click="submitOrder" :throttleTime="1000">预付款提交</up-button>
|
||||
|
||||
|
||||
<view class="submit-row">
|
||||
<view class="tips">
|
||||
<view style="margin-right: 20rpx;">共 {{ cartList.length }} 款</view>
|
||||
<view class="all">
|
||||
<text style="color: #000;">合计: </text>
|
||||
<text>¥</text>
|
||||
<block v-if="orderInfo.total_price">
|
||||
<text
|
||||
style="font-size: 32rpx;font-weight: bold;">{{ c_price(orderInfo.pay_price, 0) }}</text>
|
||||
<text>.{{ c_price(orderInfo.pay_price, 1) }}</text>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
<view style="width: 200rpx;">
|
||||
<up-button color="#20B128" shape="circle" @click="submitOrder"
|
||||
:throttleTime="1000">预付款提交</up-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<addressPopup ref="addressRef" :show="showAddress" :list="addressList" @close="showAddress = false"
|
||||
|
@ -360,6 +371,11 @@
|
|||
const passwordBoardProps = {
|
||||
title: '输入支付密码',
|
||||
onComplete(value) {
|
||||
// uni.vibrateShort({
|
||||
// success: function() {
|
||||
// console.log('success');
|
||||
// }
|
||||
// });
|
||||
password.value = value
|
||||
passwordBoardVisible.value = false
|
||||
payFn()
|
||||
|
@ -641,4 +657,32 @@
|
|||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
.fiexd-bottom {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
// height: calc(constant(safe-area-inset-bottom) + 120rpx);
|
||||
/* 适用于iOS设备 */
|
||||
// height: calc(env(safe-area-inset-bottom) + 120rpx);
|
||||
/* 适用于Android设备 */
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
padding: 20rpx;
|
||||
padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
|
||||
/* 适用于iOS设备 */
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
|
||||
/* 适用于Android设备 */
|
||||
|
||||
.submit-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pay-type-bottom {
|
||||
margin-bottom: 50rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -43,6 +43,7 @@
|
|||
}
|
||||
break;
|
||||
}
|
||||
uni.vibrateShort();
|
||||
if (refValue.value.length === props.num) {
|
||||
emits('complete', refValue.value.join(''));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,871 @@
|
|||
function Push(options) {
|
||||
this.doNotConnect = 0;
|
||||
options = options || {};
|
||||
options.heartbeat = options.heartbeat || 25000;
|
||||
options.pingTimeout = options.pingTimeout || 10000;
|
||||
this.config = options;
|
||||
this.uid = 0;
|
||||
this.channels = {};
|
||||
this.connection = null;
|
||||
this.pingTimeoutTimer = 0;
|
||||
Push.instances.push(this);
|
||||
this.createConnection();
|
||||
}
|
||||
|
||||
Push.prototype.checkoutPing = function() {
|
||||
var _this = this;
|
||||
_this.checkoutPingTimer && clearTimeout(_this.checkoutPingTimer);
|
||||
_this.checkoutPingTimer = setTimeout(function() {
|
||||
_this.checkoutPingTimer = 0;
|
||||
if (_this.connection.state === 'connected') {
|
||||
_this.connection.send('{"event":"pusher:ping","data":{}}');
|
||||
if (_this.pingTimeoutTimer) {
|
||||
clearTimeout(_this.pingTimeoutTimer);
|
||||
_this.pingTimeoutTimer = 0;
|
||||
}
|
||||
_this.pingTimeoutTimer = setTimeout(function() {
|
||||
_this.connection.closeAndClean();
|
||||
if (!_this.connection.doNotConnect) {
|
||||
_this.connection.waitReconnect();
|
||||
}
|
||||
}, _this.config.pingTimeout);
|
||||
}
|
||||
}, this.config.heartbeat);
|
||||
};
|
||||
|
||||
Push.prototype.channel = function(name) {
|
||||
return this.channels.find(name);
|
||||
};
|
||||
Push.prototype.allChannels = function() {
|
||||
return this.channels.all();
|
||||
};
|
||||
Push.prototype.createConnection = function() {
|
||||
if (this.connection) {
|
||||
throw Error('Connection already exist');
|
||||
}
|
||||
var _this = this;
|
||||
var url = this.config.url;
|
||||
|
||||
function updateSubscribed() {
|
||||
for (var i in _this.channels) {
|
||||
_this.channels[i].subscribed = false;
|
||||
}
|
||||
}
|
||||
this.connection = new Connection({
|
||||
url: url,
|
||||
app_key: this.config.app_key,
|
||||
onOpen: function() {
|
||||
_this.connection.state = 'connecting';
|
||||
_this.checkoutPing();
|
||||
},
|
||||
onMessage: function(params) {
|
||||
if (_this.pingTimeoutTimer) {
|
||||
clearTimeout(_this.pingTimeoutTimer);
|
||||
_this.pingTimeoutTimer = 0;
|
||||
}
|
||||
|
||||
params = JSON.parse(params.data);
|
||||
var event = params.event;
|
||||
var channel_name = params.channel;
|
||||
|
||||
if (event === 'pusher:pong') {
|
||||
_this.checkoutPing();
|
||||
return;
|
||||
}
|
||||
if (event === 'pusher:error') {
|
||||
throw Error(params.data.message);
|
||||
}
|
||||
var data = JSON.parse(params.data),
|
||||
channel;
|
||||
if (event === 'pusher_internal:subscription_succeeded') {
|
||||
channel = _this.channels[channel_name];
|
||||
channel.subscribed = true;
|
||||
channel.processQueue();
|
||||
channel.emit('pusher:subscription_succeeded');
|
||||
return;
|
||||
}
|
||||
if (event === 'pusher:connection_established') {
|
||||
_this.connection.socket_id = data.socket_id;
|
||||
_this.connection.updateNetworkState('connected');
|
||||
_this.subscribeAll();
|
||||
}
|
||||
if (event.indexOf('pusher_internal') !== -1) {
|
||||
console.log("Event '" + event + "' not implement");
|
||||
return;
|
||||
}
|
||||
channel = _this.channels[channel_name];
|
||||
if (channel) {
|
||||
channel.emit(event, data);
|
||||
}
|
||||
},
|
||||
onClose: function() {
|
||||
updateSubscribed();
|
||||
},
|
||||
onError: function() {
|
||||
updateSubscribed();
|
||||
}
|
||||
});
|
||||
};
|
||||
Push.prototype.disconnect = function() {
|
||||
this.connection.doNotConnect = 1;
|
||||
this.connection.close();
|
||||
};
|
||||
|
||||
Push.prototype.subscribeAll = function() {
|
||||
if (this.connection.state !== 'connected') {
|
||||
return;
|
||||
}
|
||||
for (var channel_name in this.channels) {
|
||||
//this.connection.send(JSON.stringify({event:"pusher:subscribe", data:{channel:channel_name}}));
|
||||
this.channels[channel_name].processSubscribe();
|
||||
}
|
||||
};
|
||||
|
||||
Push.prototype.unsubscribe = function(channel_name) {
|
||||
if (this.channels[channel_name]) {
|
||||
delete this.channels[channel_name];
|
||||
if (this.connection.state === 'connected') {
|
||||
this.connection.send(JSON.stringify({
|
||||
event: "pusher:unsubscribe",
|
||||
data: {
|
||||
channel: channel_name
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
||||
Push.prototype.unsubscribeAll = function() {
|
||||
var channels = Object.keys(this.channels);
|
||||
if (channels.length) {
|
||||
if (this.connection.state === 'connected') {
|
||||
for (var channel_name in this.channels) {
|
||||
this.unsubscribe(channel_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.channels = {};
|
||||
};
|
||||
Push.prototype.subscribe = function(channel_name) {
|
||||
if (this.channels[channel_name]) {
|
||||
return this.channels[channel_name];
|
||||
}
|
||||
if (channel_name.indexOf('private-') === 0) {
|
||||
return createPrivateChannel(channel_name, this);
|
||||
}
|
||||
if (channel_name.indexOf('presence-') === 0) {
|
||||
return createPresenceChannel(channel_name, this);
|
||||
}
|
||||
return createChannel(channel_name, this);
|
||||
};
|
||||
Push.instances = [];
|
||||
|
||||
function createChannel(channel_name, push) {
|
||||
var channel = new Channel(push.connection, channel_name);
|
||||
push.channels[channel_name] = channel;
|
||||
channel.subscribeCb = function() {
|
||||
push.connection.send(JSON.stringify({
|
||||
event: "pusher:subscribe",
|
||||
data: {
|
||||
channel: channel_name
|
||||
}
|
||||
}));
|
||||
}
|
||||
channel.processSubscribe();
|
||||
return channel;
|
||||
}
|
||||
|
||||
function createPrivateChannel(channel_name, push) {
|
||||
var channel = new Channel(push.connection, channel_name);
|
||||
push.channels[channel_name] = channel;
|
||||
channel.subscribeCb = function() {
|
||||
__ajax({
|
||||
url: push.config.auth,
|
||||
type: 'POST',
|
||||
data: {
|
||||
channel_name: channel_name,
|
||||
socket_id: push.connection.socket_id
|
||||
},
|
||||
success: function(data) {
|
||||
data = JSON.parse(data);
|
||||
data.channel = channel_name;
|
||||
push.connection.send(JSON.stringify({
|
||||
event: "pusher:subscribe",
|
||||
data: data
|
||||
}));
|
||||
},
|
||||
error: function(e) {
|
||||
throw Error(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
channel.processSubscribe();
|
||||
return channel;
|
||||
}
|
||||
|
||||
function createPresenceChannel(channel_name, push) {
|
||||
return createPrivateChannel(channel_name, push);
|
||||
}
|
||||
|
||||
uni.onNetworkStatusChange(function(res) {
|
||||
if (res.isConnected) {
|
||||
for (var i in Push.instances) {
|
||||
con = Push.instances[i].connection;
|
||||
con.reconnectInterval = 1;
|
||||
if (con.state === 'connecting') {
|
||||
con.connect();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function Connection(options) {
|
||||
this.dispatcher = new Dispatcher();
|
||||
__extends(this, this.dispatcher);
|
||||
var properies = ['on', 'off', 'emit'];
|
||||
for (var i in properies) {
|
||||
this[properies[i]] = this.dispatcher[properies[i]];
|
||||
}
|
||||
this.options = options;
|
||||
this.state = 'initialized'; //initialized connecting connected disconnected
|
||||
this.doNotConnect = 0;
|
||||
this.reconnectInterval = 1;
|
||||
this.connection = null;
|
||||
this.reconnectTimer = 0;
|
||||
this.connect();
|
||||
}
|
||||
|
||||
Connection.prototype.updateNetworkState = function(state) {
|
||||
var old_state = this.state;
|
||||
this.state = state;
|
||||
if (old_state !== state) {
|
||||
this.emit('state_change', {
|
||||
previous: old_state,
|
||||
current: state
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Connection.prototype.connect = function() {
|
||||
this.doNotConnect = 0;
|
||||
if (this.networkState == 'connecting' || this.networkState == 'established') {
|
||||
console.log('networkState is ' + this.networkState + ' and do not need connect');
|
||||
return;
|
||||
}
|
||||
if (this.reconnectTimer) {
|
||||
clearTimeout(this.reconnectTimer);
|
||||
this.reconnectTimer = 0;
|
||||
}
|
||||
|
||||
this.closeAndClean();
|
||||
|
||||
var options = this.options;
|
||||
var _this = this;
|
||||
_this.updateNetworkState('connecting');
|
||||
var cb = function() {
|
||||
uni.onSocketOpen(function(res) {
|
||||
_this.reconnectInterval = 1;
|
||||
if (_this.doNotConnect) {
|
||||
_this.updateNetworkState('closing');
|
||||
uni.closeSocket();
|
||||
return;
|
||||
}
|
||||
_this.updateNetworkState('established');
|
||||
if (options.onOpen) {
|
||||
options.onOpen(res);
|
||||
}
|
||||
});
|
||||
|
||||
if (options.onMessage) {
|
||||
uni.onSocketMessage(options.onMessage);
|
||||
}
|
||||
|
||||
uni.onSocketClose(function(res) {
|
||||
_this.updateNetworkState('disconnected');
|
||||
if (!_this.doNotConnect) {
|
||||
_this.waitReconnect();
|
||||
}
|
||||
if (options.onClose) {
|
||||
options.onClose(res);
|
||||
}
|
||||
});
|
||||
|
||||
uni.onSocketError(function(res) {
|
||||
_this.close();
|
||||
if (!_this.doNotConnect) {
|
||||
_this.waitReconnect();
|
||||
}
|
||||
if (options.onError) {
|
||||
options.onError(res);
|
||||
}
|
||||
});
|
||||
};
|
||||
uni.connectSocket({
|
||||
url: options.url,
|
||||
fail: function(res) {
|
||||
console.log('uni.connectSocket fail');
|
||||
console.log(res);
|
||||
_this.updateNetworkState('disconnected');
|
||||
_this.waitReconnect();
|
||||
},
|
||||
success: function() {
|
||||
|
||||
}
|
||||
});
|
||||
cb();
|
||||
}
|
||||
|
||||
Connection.prototype.connect = function() {
|
||||
this.doNotConnect = 0;
|
||||
if (this.state === 'connected') {
|
||||
console.log('networkState is "' + this.state + '" and do not need connect');
|
||||
return;
|
||||
}
|
||||
if (this.reconnectTimer) {
|
||||
clearTimeout(this.reconnectTimer);
|
||||
this.reconnectTimer = 0;
|
||||
}
|
||||
|
||||
this.closeAndClean();
|
||||
|
||||
var options = this.options;
|
||||
|
||||
this.updateNetworkState('connecting');
|
||||
|
||||
var _this = this;
|
||||
var cb = function() {
|
||||
uni.onSocketOpen(function(res) {
|
||||
_this.reconnectInterval = 1;
|
||||
if (_this.doNotConnect) {
|
||||
_this.updateNetworkState('disconnected');
|
||||
uni.closeSocket();
|
||||
return;
|
||||
}
|
||||
if (options.onOpen) {
|
||||
options.onOpen(res);
|
||||
}
|
||||
});
|
||||
|
||||
if (options.onMessage) {
|
||||
uni.onSocketMessage(options.onMessage);
|
||||
}
|
||||
|
||||
uni.onSocketClose(function(res) {
|
||||
_this.updateNetworkState('disconnected');
|
||||
if (!_this.doNotConnect) {
|
||||
_this.waitReconnect();
|
||||
}
|
||||
if (options.onClose) {
|
||||
options.onClose(res);
|
||||
}
|
||||
});
|
||||
|
||||
uni.onSocketError(function(res) {
|
||||
_this.close();
|
||||
if (!_this.doNotConnect) {
|
||||
_this.waitReconnect();
|
||||
}
|
||||
if (options.onError) {
|
||||
options.onError(res);
|
||||
}
|
||||
});
|
||||
};
|
||||
uni.connectSocket({
|
||||
url: options.url + '/app/' + options.app_key,
|
||||
fail: function(res) {
|
||||
console.log('uni.connectSocket fail');
|
||||
console.log(res);
|
||||
_this.updateNetworkState('disconnected');
|
||||
_this.waitReconnect();
|
||||
},
|
||||
success: function() {
|
||||
|
||||
}
|
||||
});
|
||||
cb();
|
||||
}
|
||||
|
||||
Connection.prototype.closeAndClean = function() {
|
||||
if (this.state === 'connected') {
|
||||
uni.closeSocket();
|
||||
}
|
||||
this.updateNetworkState('disconnected');
|
||||
};
|
||||
|
||||
Connection.prototype.waitReconnect = function() {
|
||||
if (this.state === 'connected' || this.state === 'connecting') {
|
||||
return;
|
||||
}
|
||||
if (!this.doNotConnect) {
|
||||
this.updateNetworkState('connecting');
|
||||
var _this = this;
|
||||
if (this.reconnectTimer) {
|
||||
clearTimeout(this.reconnectTimer);
|
||||
}
|
||||
this.reconnectTimer = setTimeout(function() {
|
||||
_this.connect();
|
||||
}, this.reconnectInterval);
|
||||
if (this.reconnectInterval < 1000) {
|
||||
this.reconnectInterval = 1000;
|
||||
} else {
|
||||
// 每次重连间隔增大一倍
|
||||
this.reconnectInterval = this.reconnectInterval * 2;
|
||||
}
|
||||
// 有网络的状态下,重连间隔最大2秒
|
||||
if (this.reconnectInterval > 2000 && navigator.onLine) {
|
||||
_this.reconnectInterval = 2000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connection.prototype.send = function(data) {
|
||||
if (this.state !== 'connected') {
|
||||
console.trace('networkState is "' + this.state + '", can not send ' + data);
|
||||
return;
|
||||
}
|
||||
uni.sendSocketMessage({
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
Connection.prototype.close = function() {
|
||||
this.updateNetworkState('disconnected');
|
||||
uni.closeSocket();
|
||||
}
|
||||
|
||||
var __extends = (this && this.__extends) || function(d, b) {
|
||||
for (var p in b)
|
||||
if (b.hasOwnProperty(p)) {
|
||||
d[p] = b[p];
|
||||
}
|
||||
|
||||
function __() {
|
||||
this.constructor = d;
|
||||
}
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
|
||||
function Channel(connection, channel_name) {
|
||||
this.subscribed = false;
|
||||
this.dispatcher = new Dispatcher();
|
||||
this.connection = connection;
|
||||
this.channelName = channel_name;
|
||||
this.subscribeCb = null;
|
||||
this.queue = [];
|
||||
__extends(this, this.dispatcher);
|
||||
var properies = ['on', 'off', 'emit'];
|
||||
for (var i in properies) {
|
||||
this[properies[i]] = this.dispatcher[properies[i]];
|
||||
}
|
||||
}
|
||||
|
||||
Channel.prototype.processSubscribe = function() {
|
||||
if (this.connection.state !== 'connected') {
|
||||
return;
|
||||
}
|
||||
this.subscribeCb();
|
||||
};
|
||||
|
||||
Channel.prototype.processQueue = function() {
|
||||
if (this.connection.state !== 'connected' || !this.subscribed) {
|
||||
return;
|
||||
}
|
||||
for (var i in this.queue) {
|
||||
this.queue[i]();
|
||||
}
|
||||
this.queue = [];
|
||||
};
|
||||
|
||||
Channel.prototype.trigger = function(event, data) {
|
||||
if (event.indexOf('client-') !== 0) {
|
||||
throw new Error("Event '" + event + "' should start with 'client-'");
|
||||
}
|
||||
var _this = this;
|
||||
this.queue.push(function() {
|
||||
_this.connection.send(JSON.stringify({
|
||||
event: event,
|
||||
data: data,
|
||||
channel: _this.channelName
|
||||
}));
|
||||
});
|
||||
this.processQueue();
|
||||
};
|
||||
|
||||
////////////////
|
||||
var Collections = (function() {
|
||||
var exports = {};
|
||||
|
||||
function extend(target) {
|
||||
var sources = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
sources[_i - 1] = arguments[_i];
|
||||
}
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var extensions = sources[i];
|
||||
for (var property in extensions) {
|
||||
if (extensions[property] && extensions[property].constructor &&
|
||||
extensions[property].constructor === Object) {
|
||||
target[property] = extend(target[property] || {}, extensions[property]);
|
||||
} else {
|
||||
target[property] = extensions[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
exports.extend = extend;
|
||||
|
||||
function stringify() {
|
||||
var m = ["Push"];
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (typeof arguments[i] === "string") {
|
||||
m.push(arguments[i]);
|
||||
} else {
|
||||
m.push(safeJSONStringify(arguments[i]));
|
||||
}
|
||||
}
|
||||
return m.join(" : ");
|
||||
}
|
||||
|
||||
exports.stringify = stringify;
|
||||
|
||||
function arrayIndexOf(array, item) {
|
||||
var nativeIndexOf = Array.prototype.indexOf;
|
||||
if (array === null) {
|
||||
return -1;
|
||||
}
|
||||
if (nativeIndexOf && array.indexOf === nativeIndexOf) {
|
||||
return array.indexOf(item);
|
||||
}
|
||||
for (var i = 0, l = array.length; i < l; i++) {
|
||||
if (array[i] === item) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
exports.arrayIndexOf = arrayIndexOf;
|
||||
|
||||
function objectApply(object, f) {
|
||||
for (var key in object) {
|
||||
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
||||
f(object[key], key, object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.objectApply = objectApply;
|
||||
|
||||
function keys(object) {
|
||||
var keys = [];
|
||||
objectApply(object, function(_, key) {
|
||||
keys.push(key);
|
||||
});
|
||||
return keys;
|
||||
}
|
||||
|
||||
exports.keys = keys;
|
||||
|
||||
function values(object) {
|
||||
var values = [];
|
||||
objectApply(object, function(value) {
|
||||
values.push(value);
|
||||
});
|
||||
return values;
|
||||
}
|
||||
|
||||
exports.values = values;
|
||||
|
||||
function apply(array, f, context) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
f.call(context || (window), array[i], i, array);
|
||||
}
|
||||
}
|
||||
|
||||
exports.apply = apply;
|
||||
|
||||
function map(array, f) {
|
||||
var result = [];
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
result.push(f(array[i], i, array, result));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
exports.map = map;
|
||||
|
||||
function mapObject(object, f) {
|
||||
var result = {};
|
||||
objectApply(object, function(value, key) {
|
||||
result[key] = f(value);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
exports.mapObject = mapObject;
|
||||
|
||||
function filter(array, test) {
|
||||
test = test || function(value) {
|
||||
return !!value;
|
||||
};
|
||||
var result = [];
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
if (test(array[i], i, array, result)) {
|
||||
result.push(array[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
exports.filter = filter;
|
||||
|
||||
function filterObject(object, test) {
|
||||
var result = {};
|
||||
objectApply(object, function(value, key) {
|
||||
if ((test && test(value, key, object, result)) || Boolean(value)) {
|
||||
result[key] = value;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
exports.filterObject = filterObject;
|
||||
|
||||
function flatten(object) {
|
||||
var result = [];
|
||||
objectApply(object, function(value, key) {
|
||||
result.push([key, value]);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
exports.flatten = flatten;
|
||||
|
||||
function any(array, test) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
if (test(array[i], i, array)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
exports.any = any;
|
||||
|
||||
function all(array, test) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
if (!test(array[i], i, array)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
exports.all = all;
|
||||
|
||||
function encodeParamsObject(data) {
|
||||
return mapObject(data, function(value) {
|
||||
if (typeof value === "object") {
|
||||
value = safeJSONStringify(value);
|
||||
}
|
||||
return encodeURIComponent(base64_1["default"](value.toString()));
|
||||
});
|
||||
}
|
||||
|
||||
exports.encodeParamsObject = encodeParamsObject;
|
||||
|
||||
function buildQueryString(data) {
|
||||
var params = filterObject(data, function(value) {
|
||||
return value !== undefined;
|
||||
});
|
||||
return map(flatten(encodeParamsObject(params)), util_1["default"].method("join", "=")).join("&");
|
||||
}
|
||||
|
||||
exports.buildQueryString = buildQueryString;
|
||||
|
||||
function decycleObject(object) {
|
||||
var objects = [],
|
||||
paths = [];
|
||||
return (function derez(value, path) {
|
||||
var i, name, nu;
|
||||
switch (typeof value) {
|
||||
case 'object':
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
for (i = 0; i < objects.length; i += 1) {
|
||||
if (objects[i] === value) {
|
||||
return {
|
||||
$ref: paths[i]
|
||||
};
|
||||
}
|
||||
}
|
||||
objects.push(value);
|
||||
paths.push(path);
|
||||
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
||||
nu = [];
|
||||
for (i = 0; i < value.length; i += 1) {
|
||||
nu[i] = derez(value[i], path + '[' + i + ']');
|
||||
}
|
||||
} else {
|
||||
nu = {};
|
||||
for (name in value) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, name)) {
|
||||
nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
|
||||
}
|
||||
}
|
||||
}
|
||||
return nu;
|
||||
case 'number':
|
||||
case 'string':
|
||||
case 'boolean':
|
||||
return value;
|
||||
}
|
||||
}(object, '$'));
|
||||
}
|
||||
|
||||
exports.decycleObject = decycleObject;
|
||||
|
||||
function safeJSONStringify(source) {
|
||||
try {
|
||||
return JSON.stringify(source);
|
||||
} catch (e) {
|
||||
return JSON.stringify(decycleObject(source));
|
||||
}
|
||||
}
|
||||
|
||||
exports.safeJSONStringify = safeJSONStringify;
|
||||
return exports;
|
||||
})();
|
||||
|
||||
var Dispatcher = (function() {
|
||||
function Dispatcher(failThrough) {
|
||||
this.callbacks = new CallbackRegistry();
|
||||
this.global_callbacks = [];
|
||||
this.failThrough = failThrough;
|
||||
}
|
||||
Dispatcher.prototype.on = function(eventName, callback, context) {
|
||||
this.callbacks.add(eventName, callback, context);
|
||||
return this;
|
||||
};
|
||||
Dispatcher.prototype.on_global = function(callback) {
|
||||
this.global_callbacks.push(callback);
|
||||
return this;
|
||||
};
|
||||
Dispatcher.prototype.off = function(eventName, callback, context) {
|
||||
this.callbacks.remove(eventName, callback, context);
|
||||
return this;
|
||||
};
|
||||
Dispatcher.prototype.emit = function(eventName, data) {
|
||||
var i;
|
||||
for (i = 0; i < this.global_callbacks.length; i++) {
|
||||
this.global_callbacks[i](eventName, data);
|
||||
}
|
||||
var callbacks = this.callbacks.get(eventName);
|
||||
if (callbacks && callbacks.length > 0) {
|
||||
for (i = 0; i < callbacks.length; i++) {
|
||||
callbacks[i].fn.call(callbacks[i].context || (window), data);
|
||||
}
|
||||
} else if (this.failThrough) {
|
||||
this.failThrough(eventName, data);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
return Dispatcher;
|
||||
}());
|
||||
|
||||
var CallbackRegistry = (function() {
|
||||
function CallbackRegistry() {
|
||||
this._callbacks = {};
|
||||
}
|
||||
CallbackRegistry.prototype.get = function(name) {
|
||||
return this._callbacks[prefix(name)];
|
||||
};
|
||||
CallbackRegistry.prototype.add = function(name, callback, context) {
|
||||
var prefixedEventName = prefix(name);
|
||||
this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
|
||||
this._callbacks[prefixedEventName].push({
|
||||
fn: callback,
|
||||
context: context
|
||||
});
|
||||
};
|
||||
CallbackRegistry.prototype.remove = function(name, callback, context) {
|
||||
if (!name && !callback && !context) {
|
||||
this._callbacks = {};
|
||||
return;
|
||||
}
|
||||
var names = name ? [prefix(name)] : Collections.keys(this._callbacks);
|
||||
if (callback || context) {
|
||||
this.removeCallback(names, callback, context);
|
||||
} else {
|
||||
this.removeAllCallbacks(names);
|
||||
}
|
||||
};
|
||||
CallbackRegistry.prototype.removeCallback = function(names, callback, context) {
|
||||
Collections.apply(names, function(name) {
|
||||
this._callbacks[name] = Collections.filter(this._callbacks[name] || [], function(
|
||||
oning) {
|
||||
return (callback && callback !== oning.fn) ||
|
||||
(context && context !== oning.context);
|
||||
});
|
||||
if (this._callbacks[name].length === 0) {
|
||||
delete this._callbacks[name];
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
CallbackRegistry.prototype.removeAllCallbacks = function(names) {
|
||||
Collections.apply(names, function(name) {
|
||||
delete this._callbacks[name];
|
||||
}, this);
|
||||
};
|
||||
return CallbackRegistry;
|
||||
}());
|
||||
|
||||
function prefix(name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
function __ajax(options) {
|
||||
options = options || {};
|
||||
options.type = (options.type || 'GET').toUpperCase();
|
||||
options.dataType = options.dataType || 'json';
|
||||
var params = formatParams(options.data);
|
||||
|
||||
var xhr;
|
||||
if (window.XMLHttpRequest) {
|
||||
xhr = new XMLHttpRequest();
|
||||
} else {
|
||||
xhr = ActiveXObject('Microsoft.XMLHTTP');
|
||||
}
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
var status = xhr.status;
|
||||
if (status >= 200 && status < 300) {
|
||||
options.success && options.success(xhr.responseText, xhr.responseXML);
|
||||
} else {
|
||||
options.error && options.error(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (options.type === 'GET') {
|
||||
xhr.open('GET', options.url + '?' + params, true);
|
||||
xhr.send(null);
|
||||
} else if (options.type === 'POST') {
|
||||
xhr.open('POST', options.url, true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send(params);
|
||||
}
|
||||
}
|
||||
|
||||
function formatParams(data) {
|
||||
var arr = [];
|
||||
for (var name in data) {
|
||||
arr.push(encodeURIComponent(name) + '=' + encodeURIComponent(data[name]));
|
||||
}
|
||||
return arr.join('&');
|
||||
}
|
||||
|
||||
export default Push
|
Loading…
Reference in New Issue