This commit is contained in:
zmj 2024-06-27 09:11:32 +08:00
commit 25517afb79
17 changed files with 2124 additions and 725 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -17,61 +17,73 @@
<view v-else>
<view class="tabs">
<text @click="currentTab=1" :class="{actText:currentTab==1}">开通{{Role==1?'行业会员':'商户'}} </text>
<text @click="currentTab=2,getCount(),getLists()" :class="{actText:currentTab==2}"> 已开通列表</text>
<view class="lines" :class="{actLine:currentTab==2}" />
<text @click="currentTab = 1" :class="{ actText: currentTab == 1 }">开通{{ Role == 1 ? '行业会员' : '商户' }} </text>
<text @click="currentTab = 2, getCount(), getLists()" :class="{ actText: currentTab == 2 }"> 已开通列表</text>
<view class="lines" :class="{ actLine: currentTab == 2 }" />
</view>
<!-- tabs1 -->
<block v-if='currentTab==1'>
<block v-if='currentTab == 1'>
<view class="card card1">
<view class="card1-tit">
{{Role==1?'行业会员':'商户'}}开通报备
{{ Role == 1 ? '行业会员' : '商户' }}开通报备
</view>
<up-form labelPosition="left" :model="formData" :borderBottom='false'>
<up-form-item label="" prop="userInfo.name">
<up-form-item label="">
<up-input v-model="formData.real_name" border="none" prefixIcon="account" placeholder="请输入真实姓名"
:customStyle="{background:'#F3F3F3',padding:'20rpx','border-radius':'30rpx'}"
:placeholderStyle="{color:'#444444'}"
:prefixIconStyle="{'margin-right':'40rpx'}"></up-input>
:customStyle="{ background: '#F3F3F3', padding: '20rpx', 'border-radius': '30rpx' }"
:placeholderStyle="{ color: '#444444' }" :prefixIconStyle="{ 'margin-right': '40rpx' }"></up-input>
</up-form-item>
<up-form-item label="" prop="userInfo.name">
<up-form-item label="">
<up-input v-model="formData.mobile" border="none" prefixIcon="phone" placeholder="请输入电话号码"
:customStyle="{background:'#F3F3F3',padding:'20rpx','border-radius':'30rpx'}"
:placeholderStyle="{color:'#444444'}"
:prefixIconStyle="{'margin-right':'40rpx'}"></up-input>
:customStyle="{ background: '#F3F3F3', padding: '20rpx', 'border-radius': '30rpx' }"
:placeholderStyle="{ color: '#444444' }" :prefixIconStyle="{ 'margin-right': '40rpx' }"></up-input>
</up-form-item>
<up-form-item label="" prop="userInfo.name">
<view @click="showPop=true" style="width: 100%;">
<up-input style="pointer-events: none" v-model="formData.address" border="none"
prefixIcon="map" readonly placeholder="点击选择地址" :customStyle="{background:'#F3F3F3',padding:'20rpx',
'border-radius':'30rpx'
}" :placeholderStyle="{color:'#444444'}" :prefixIconStyle="{'margin-right':'40rpx'}"
<up-form-item label="">
<view @click="showPop = true" style="width: 100%;">
<up-input style="pointer-events: none" v-model="formData.address" border="none" prefixIcon="map"
readonly placeholder="点击选择地址" :customStyle="{
background: '#F3F3F3', padding: '20rpx',
'border-radius': '30rpx'
}" :placeholderStyle="{ color: '#444444' }" :prefixIconStyle="{ 'margin-right': '40rpx' }"
suffixIcon='arrow-down'></up-input>
</view>
</up-form-item>
<up-form-item label="" prop="userInfo.name" v-if='Role==1'>
<view @click="showPop1=true" style="width: 100%;">
<up-form-item label="" v-if='Role == 1'>
<view @click="showPop1 = true" style="width: 100%;">
<up-input style="pointer-events: none" v-model="formData.label_name" border="none"
prefixIcon="man-add" readonly placeholder="点击选择用户身份" :customStyle="{background:'#F3F3F3',padding:'20rpx',
'border-radius':'30rpx'
}" :placeholderStyle="{color:'#444444'}" :prefixIconStyle="{'margin-right':'40rpx'}"
prefixIcon="man-add" readonly placeholder="点击选择用户身份" :customStyle="{
background: '#F3F3F3', padding: '20rpx',
'border-radius': '30rpx'
}" :placeholderStyle="{ color: '#444444' }" :prefixIconStyle="{ 'margin-right': '40rpx' }"
suffixIcon='arrow-down'></up-input>
</view>
</up-form-item>
<up-form-item label="">
<view style="width: 100%;display: flex;align-items: center;justify-content: space-between;">
<view class="">
<up-input v-model="formData.code" border="none" prefixIcon="tags" placeholder="请输入验证码"
:customStyle="{
background: '#F3F3F3', padding: '20rpx',
'border-radius': '30rpx'
}" :placeholderStyle="{ color: '#444444' }" :prefixIconStyle="{ 'margin-right': '40rpx' }"></up-input>
</view>
<text class='btn-text' style="color: grey;" v-if='cutDown'>重新获取({{ cutDown }})</text>
<text @click="getCode" class='btn-text' v-else> {{ flag ? '获取验证码' : '重新获取' }} </text>
</view>
</up-form-item>
</up-form>
<view class="store-info">
报备人:{{STORE_INFO.name}}
报备人:{{ STORE_INFO.name }}
</view>
</view>
<view class="submit-btn" @click="submit">
<!-- <up-button text="完成并收款" size='large' :customStyle="{height:'100rpx',fontSize:'50rpx'}" @click="submit"
shape="circle" color="#50C758"></up-button> -->
<view
style='width: 710rpx;height: 100rpx;text-align: center;line-height: 100rpx;text-align: center;color: white;background-color: #33B83A;border-radius: 50rpx;font-size:40rpx ;'>
{{Role==1?'完成并收款':'完成'}}
{{ Role == 1 ? '完成并收款' : '完成' }}
</view>
</view>
@ -82,7 +94,7 @@
<view class="vip-card">
<text>当前已开通</text>
<up-count-to :startVal="0" :endVal="count"></up-count-to>
<text>{{Role==1?'行业会员':'商户'}}</text>
<text>{{ Role == 1 ? '行业会员' : '商户' }}</text>
</view>
<view class="table">
@ -90,116 +102,127 @@
<!-- 表头行 -->
<uni-tr>
<uni-th width="20" align="center">序号</uni-th>
<uni-th width="50" align="center" v-if='Role==1'>行业会员</uni-th>
<uni-th width="50" align="center" v-if='Role==1'>经营资金</uni-th>
<uni-th width="50" align="center" v-if='Role==4'>开通时间</uni-th>
<uni-th width="50" align="center" v-if='Role==4'>商户</uni-th>
<uni-th width="50" align="center" v-if='Role==1'>角色</uni-th>
<uni-th width="50" align="center" v-if='Role == 1'>行业会员</uni-th>
<uni-th width="50" align="center" v-if='Role == 1'>经营资金</uni-th>
<uni-th width="50" align="center" v-if='Role == 4'>开通时间</uni-th>
<uni-th width="50" align="center" v-if='Role == 4'>商户</uni-th>
<uni-th width="50" align="center" v-if='Role == 1'>角色</uni-th>
<uni-th width="50" align="center">状态</uni-th>
</uni-tr>
<!-- 表格数据行 -->
<uni-tr v-for="(item,index) in lists" :key="item.order_id">
<uni-td align="center">{{index+1}}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==1'>{{item.real_name}}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==1'>{{item.price}}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==4'>{{item.create_time}}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==4'>{{item.nickname}}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==1'>{{item.label_name}}</uni-td>
<uni-tr v-for="(item, index) in lists" :key="item.order_id">
<uni-td align="center">{{ index + 1 }}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role == 1'>{{ item.real_name }}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role == 1'>{{ item.price }}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role == 4'>{{ item.create_time }}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role == 4'>{{ item.nickname }}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role == 1'>{{ item.label_name }}</uni-td>
<uni-td style="font-size: 20rpx;" align="center">
<view v-if="item.paid ==1 ||Role==4">已开通</view>
<view v-else @click="upadtaStatus(item)" style="color:#33B83A ;">未开通,查询</view>
<view v-if="item.paid == 1 || Role == 4">已开通</view>
<view v-else style="color:#33B83A ;">
<view @click="upadtaStatus(item)">
未开通,查询
</view>
<view @click="rePay(item)">
重新支付
</view>
</view>
</uni-td>
</uni-tr>
</uni-table>
</view>
</block>
</view>
<view style="height: 50rpx;" />
<!-- 地址选择器 -->
<up-popup :show="showPop" @close="showPop=false" @open="showPop=true" :round="10">
<up-popup :show="showPop" @close="showPop = false" @open="showPop = true" :round="10">
<view style="padding: 20rpx;">
<up-tabs :list="tabsList" @change='addressTbasChange' :current='currentAddressIndex' lineColor='#20B128'
:activeStyle="{color:'#20B128'}"></up-tabs>
:activeStyle="{ color: '#20B128' }"></up-tabs>
<up-line style="margin-top:20rpx "></up-line>
<view class="address-content" v-if='currentAddressIndex==0'>
<view class="address-li" :class='{act:item.city_code==formData.city}' v-for="item in addressList.city"
<view class="address-content" v-if='currentAddressIndex == 0'>
<view class="address-li" :class='{ act: item.city_code == formData.city }' v-for="item in addressList.city"
:key="item.city_code" @click="addressLiClick(0, item)">
<text>{{item.city_name}}</text>
<up-icon name="arrow-right" :color="item.city_code==formData.city ?'#20B128':'#777777'" />
<text>{{ item.city_name }}</text>
<up-icon name="arrow-right" :color="item.city_code == formData.city ? '#20B128' : '#777777'" />
</view>
</view>
<view class="address-content" v-else-if='currentAddressIndex==1'>
<view class="address-li" v-for="item in addressList.area" @click="addressLiClick(1,item)"
:key="item.area_code" :class='{act:item.area_code==formData.area}'>
<text>{{item.area_name}}</text>
<up-icon name="arrow-right" :color="item.area_code==formData.area ?'#20B128':'#777777'" />
<view class="address-content" v-else-if='currentAddressIndex == 1'>
<view class="address-li" v-for="item in addressList.area" @click="addressLiClick(1, item)"
:key="item.area_code" :class='{ act: item.area_code == formData.area }'>
<text>{{ item.area_name }}</text>
<up-icon name="arrow-right" :color="item.area_code == formData.area ? '#20B128' : '#777777'" />
</view>
</view>
<view class="address-content" v-else-if='currentAddressIndex==2'>
<view class="address-li" v-for="item in addressList.street" @click="addressLiClick(2,item)"
:key="item.street_code" :class='{act:item.street_code==formData.street}'>
<text>{{item.street_name}}</text>
<up-icon name="arrow-right" :color="item.street_code==formData.street ?'#20B128':'#777777'" />
<view class="address-content" v-else-if='currentAddressIndex == 2'>
<view class="address-li" v-for="item in addressList.street" @click="addressLiClick(2, item)"
:key="item.street_code" :class='{ act: item.street_code == formData.street }'>
<text>{{ item.street_name }}</text>
<up-icon name="arrow-right" :color="item.street_code == formData.street ? '#20B128' : '#777777'" />
</view>
</view>
<view class="address-content" v-else-if='currentAddressIndex==3'>
<view class="address-li" v-for="item in addressList.village" @click="addressLiClick(3,item)"
:key="item.village_code" :class='{act:item.village_code==formData.village}'>
<text>{{item.village_name}}</text>
<up-icon name="arrow-right" :color="item.village_code==formData.village ?'#20B128':'#777777'" />
<view class="address-content" v-else-if='currentAddressIndex == 3'>
<view class="address-li" v-for="item in addressList.village" @click="addressLiClick(3, item)"
:key="item.village_code" :class='{ act: item.village_code == formData.village }'>
<text>{{ item.village_name }}</text>
<up-icon name="arrow-right" :color="item.village_code == formData.village ? '#20B128' : '#777777'" />
</view>
</view>
<view class="address-content" v-else-if='currentAddressIndex==4'>
<view class="address-li" :class='{act:item.id==formData.brigade}' v-for="item in addressList.brigade"
:key="item.id" @click="addressLiClick(4,item)">
<text>{{item.brigade_name}}</text>
<up-icon name="arrow-right" :color="item.id==formData.brigade ?'#20B128':'#777777'" />
<view class="address-content" v-else-if='currentAddressIndex == 4'>
<view class="address-li" :class='{ act: item.id == formData.brigade }' v-for="item in addressList.brigade"
:key="item.id" @click="addressLiClick(4, item)">
<text>{{ item.brigade_name }}</text>
<up-icon name="arrow-right" :color="item.id == formData.brigade ? '#20B128' : '#777777'" />
</view>
</view>
</view>
</up-popup>
<up-picker :show="showPop1" :columns="columns" @confirm='conformRole' @cancel='showPop1=false'
@close="showPop1=false" @open="showPop1=true" keyName='label_name' confirmColor='#33B83A'></up-picker>
<up-picker :show="showPop1" :columns="columns" @confirm='conformRole' @cancel='showPop1 = false' @close="showPop1 = false"
@open="showPop1 = true" keyName='label_name' confirmColor='#33B83A'></up-picker>
</template>
<script setup>
import {
import {
reactive,
ref
} from 'vue';
import {
} from 'vue';
import useUserStore from "@/store/user";
import {
provinceListApi,
cityListApi,
areaListApi,
streetListApi,
villageListApi,
brigadeListApi
} from "@/api/address.js"
import {
} from "@/api/address.js"
import {
vipRechargeApi,
rechargeCountApi,
reVipRechargeApi,
rechargeListsApi,
updataOrderApi,
getStoreByPhone,
getUserLabel,
getUserShip,
getCreateLists
} from "@/api/user.js"
import {
getCreateLists,
getReportingSms
} from "@/api/user.js"
import Push from "@/utils/push.js"
import {
onPullDownRefresh,
onLoad
} from "@dcloudio/uni-app"
} from "@dcloudio/uni-app"
import {
config
} from "@/config/app.js"
const showPop1 = ref(false)
const Role = ref('')
const range = ref({})
const columns = ref([])
const showModa = ref(true)
const storePhone = ref('')
const confirmStore = () => {
const showPop1 = ref(false)
const Role = ref('')
const range = ref({})
const columns = ref([])
const showModa = ref(true)
const storePhone = ref('')
const confirmStore = () => {
getStoreByPhone({
phone: storePhone.value
}).then(res => {
@ -210,16 +233,15 @@
}).catch(err => {
uni.$u.toast('未查到店铺信息,请检查手机号码')
})
}
//
let STORE_INFO = reactive({
}
//
let STORE_INFO = reactive({
id: ""
})
})
const setPhoneOneDay = () => {
//
const setPhoneOneDay = () => {
if (uni.getStorageSync('VIP_PHONE')) return;
const currentDate = new Date();
const nextDay = new Date(currentDate);
@ -228,9 +250,8 @@
time: nextDay,
phone: storePhone.value
}));
}
const getPhoneOneDay = () => {
}
const getPhoneOneDay = () => {
if (uni.getStorageSync('VIP_PHONE')) {
let data = JSON.parse(uni.getStorageSync('VIP_PHONE'))
if (new Date() > data.time) {
@ -239,12 +260,34 @@
storePhone.value = data.phone
}
}
}
}
//
//
const cutDown = ref(0)
const flag = ref(true)
const code = ref('')
const checkPhone = (phone) => {
const regex = /^1[3-9]\d{9}$/;
return regex.test(formData.mobile) ? true : false
}
const getCode = async () => {
if (!checkPhone(formData.mobile)) return uni.$u.toast('请输入正确的手机号')
await getReportingSms({
account: formData.mobile
})
flag.value = false
cutDown.value = 60
let timer = setInterval(() => {
cutDown.value--
if (cutDown.value <= 0) clearInterval(timer)
}, 1000)
}
//
const currentTab = ref(1)
const formData = reactive({
const currentTab = ref(1)
const formData = reactive({
store_id: STORE_INFO.id,
mobile: "",
province: 510000,
@ -252,45 +295,58 @@
area: "",
street: "",
village: "",
brigade: "",
real_name: "",
auth_code: "",
address: "",
label_name: "",
label_id: "",
user_ship: ''
})
user_ship: '',
code: '',
const conformRole = (e) => {
// store_id: STORE_INFO.id,
// mobile: "19130550023",
// province: 510000,
// city: '510500',
// area: "510503",
// street: "510503102",
// village: "510503102201",
// real_name: "",
// auth_code: "131197337173621549",
// address: "",
// label_name: "",
// label_id: "4",
// user_ship: '1',
// code: ''
})
const conformRole = (e) => {
formData.label_name = e.value[0].label_name
formData.label_id = e.value[0].label_id
showPop1.value = false
}
}
//
const showPop = ref(false)
const currentAddressIndex = ref(0)
const currentAddressList = () => {
//
const showPop = ref(false)
const currentAddressIndex = ref(0)
const currentAddressList = () => {
if (!formData.city) return [0, 'city'];
else if (formData.area) return [1, 'area'];
else if (formData.street) return [2, 'street'];
else if (formData.village) return [3, 'village'];
else if (formData.brigade) return [4, 'brigade'];
}
}
const addressTbasChange = (e) => {
const addressTbasChange = (e) => {
currentAddressIndex.value = e.index
}
const addressList = reactive({
}
const addressList = reactive({
city: [],
area: [],
street: [],
village: [],
brigade: []
})
const addressLiClick = async (i, item) => {
})
const addressLiClick = async (i, item) => {
if (i == 0) {
formData.city = item.city_code
tabsList[0].name = item.city_name
@ -335,16 +391,15 @@
formData.address = tabsList[0].name + tabsList[1].name + tabsList[2].name + tabsList[3].name + tabsList[4]
.name
return currentAddressIndex.value++
}
const getCityList = async () => {
}
const getCityList = async () => {
let res = await cityListApi({
province_code: formData.province
})
addressList.city = res.data
}
getCityList()
const tabsList = reactive(
}
getCityList()
const tabsList = reactive(
[{
name: "请选择"
},
@ -366,34 +421,51 @@
},
]);
const submit = async () => {
//
// scoket
let timerInvol = null
const userInfo = useUserStore().userInfo;
const connection = new Push({
url: config.WSS_URL, // websocket
app_key: '2ce3ce22329517213caa7dad261f5695',
});
// user-1
const user_channel = connection.subscribe(`wechat_mmp_${userInfo.id}`);
user_channel.on('message', function (data) {
try {
clearTimeout(timerInvol);
paySuccessToTabs2()
} catch (error) { }
});
const submit = async () => {
if (!formData.real_name) return uni.$u.toast('请填写真实姓名');
if (!formData.mobile) return uni.$u.toast('请填写电话号码');
if (!formData.code) return uni.$u.toast('请输入短信验证码');
if (!formData.label_id) return uni.$u.toast('请选择用户身份');
if (!formData.address) return uni.$u.toast('请选择地址');
formData.store_id = STORE_INFO.id
if (Role.value == 1) {
// formData.recharge_type = 'INDUSTRYMEMBERS'
// formData.user_ship = 1
// vipRechargeApi(formData).then(res => {})
// return
uni.scanCode({
success: function(res) {
success: function (res) {
if (String(res.result.length) != 18) return uni.$u.toast('二维码未扫描完整');
uni.showLoading({
title: '支付中...'
});
formData.auth_code = res.result
formData.recharge_type = 'INDUSTRYMEMBERS'
formData.user_ship = 1
vipRechargeApi(formData).then(res => {
uni.$u.toast('操作成功');
currentTab.value = 2
formData.real_name = ''
formData.mobile = ''
formData.address = ''
formData.label_name = ''
formData.city = ''
formData.area = ''
formData.street = ''
formData.village = ''
formData.brigade = ''
currentAddressIndex.value = 0
tabsList.forEach(item => {
item.name = '请选择'
})
getCount()
getLists()
timerInvol = setTimeout(() => {
uni.hideLoading();
uni.$u.toast('支付超时');
}, 30000)
})
}
@ -414,7 +486,9 @@
formData.street = ''
formData.village = ''
formData.brigade = ''
formData.code = ''
currentAddressIndex.value = 0
cutDown.value = 0
tabsList.forEach(item => {
item.name = '请选择'
})
@ -422,22 +496,72 @@
getCount()
})
}
}
const rePay = (item) => {
uni.scanCode({
success: function (res) {
if (String(res.result.length) != 18) return uni.$u.toast('二维码未扫描完整');
uni.showLoading({
title: '支付中...'
});
reVipRechargeApi({
id: item.id,
auth_code: res.result
}).then(res => {
timerInvol = setTimeout(() => {
uni.hideLoading();
uni.$u.toast('支付超时');
}, 30000)
})
}
});
}
//
const count = ref(0)
const getCount = async () => {
// formDatatabs2
const paySuccessToTabs2 = () => {
uni.hideLoading()
uni.showToast({
title: '支付成功',
duration: 2000,
success() {
currentTab.value = 2
formData.real_name = ''
formData.mobile = ''
formData.address = ''
formData.label_name = ''
formData.city = ''
formData.area = ''
formData.street = ''
formData.village = ''
formData.brigade = ''
formData.code = ''
currentAddressIndex.value = 0
cutDown.value = 0
tabsList.forEach(item => {
item.name = '请选择'
})
setTimeout(() => {
getLists()
getCount()
}, 500); // 1
}
});
}
//
const count = ref(0)
const getCount = async () => {
if (Role.value == 4) return;
let res = await rechargeCountApi({
store_id: STORE_INFO.id
})
count.value = res.data.count
}
}
//
const lists = ref([])
const getLists = async () => {
//
const lists = ref([])
const getLists = async () => {
if (Role.value == 1) {
let res = await rechargeListsApi({
store_id: STORE_INFO.id,
@ -450,26 +574,27 @@
})
lists.value = res.data.lists
count.value = res.data.count
}
}
}
getCount()
getLists()
getCount()
getLists()
const upadtaStatus = (item) => {
const upadtaStatus = (item) => {
updataOrderApi({
order_no: item.order_id,
recharge: 1
}).then(res => {
getCount()
getLists()
})
}
}
onLoad(() => {
onLoad(() => {
getUserShip().then(res => {
console.log(res)
range.value = res.data.lists.map(item => {
return {
value: item.id,
@ -481,19 +606,19 @@
columns.value = [res.data.lists]
})
getPhoneOneDay()
})
})
onPullDownRefresh(() => {
onPullDownRefresh(() => {
getCount()
getLists()
setTimeout(() => {
uni.stopPullDownRefresh()
}, 500)
})
})
</script>
<style lang='scss'>
.tabs {
.tabs {
background-color: #fff;
width: 100vw;
box-sizing: border-box;
@ -523,17 +648,17 @@
.actLine {
left: calc(75vw - 35rpx);
}
}
}
.card {
.card {
width: 710rpx;
margin: 20rpx auto;
background-color: #fff;
box-sizing: border-box;
border-radius: 10rpx;
}
}
.card1 {
.card1 {
padding: 52rpx 30rpx;
.card1-tit {
@ -549,9 +674,9 @@
text-align: center;
margin-top: 30rpx;
}
}
}
.submit-btn {
.submit-btn {
/* height: 200rpx; */
position: fixed;
bottom: 50rpx;
@ -559,10 +684,10 @@
left: 50%;
transform: translateX(-50%);
}
}
.vip-card {
.vip-card {
width: 690rpx;
height: 270rpx;
background-image: url('https://lihai001.oss-cn-chengdu.aliyuncs.com/attach/4a92b202406162207212332.png');
@ -581,17 +706,17 @@
color: #7B5232;
}
}
}
.table {
.table {
width: 710rpx;
box-sizing: border-box;
font-size: 30rpx;
margin: 0 auto;
}
}
.address-content {
.address-content {
padding: 20rpx;
height: 50vh;
overflow-y: auto;
@ -608,17 +733,26 @@
.act {
color: #20B128;
}
}
}
.uni-table-th {
.uni-table-th {
padding: 10rpx 0 !important;
}
}
.uni-table-td {
.uni-table-td {
padding: 10rpx 0 !important;
}
}
.slot-content {
.slot-content {
padding-bottom: 50rpx;
}
}
.code-btn {
display: flex;
align-items: center;
}
.btn-text {
color: #20B128;
}
</style>

View File

@ -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
}
}
]
}
],

View File

@ -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,
@ -254,14 +255,18 @@
checkAll.value = 0
}
res.data.lists = res.data.lists.map(item => {
if(!item.price) item.price = item.sell; // price
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;
}

View File

@ -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 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 {
.line-through {
text-decoration: line-through;
}
.shop-content-li-l {
font-size: 22rpx;
width: 70rpx;
text-align-last: justify;
margin-right: 6rpx;
}
}
.tag {
font-size: 16rpx;
color: #A17C3A;
background-color: #F3E7C0;
padding: 8rpx 4rpx;
margin-left: 4rpx;
display: flex;
align-items: center;
.num {
width: 60rpx;
text-align: 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>

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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"

View File

@ -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

View File

@ -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,13 +71,25 @@
</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="m-card order-remark">
<view class="head-title">
<text>订单备注</text>
<text>0/200</text>
</view>
<up-textarea style="background-color: #F6F6F6;" v-model="formData.remark" placeholder="暂无备注内容"
:height="40"></up-textarea>
</view>
<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">
@ -97,7 +109,8 @@
<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 style="margin-left: 20rpx;font-size: 22rpx;color: #FFB76D;">(
可用¥{{userInfo.now_money}}
)</text>
</view>
<view class="icon" @click="onChoosePaytype(3)">
@ -111,7 +124,8 @@
<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 style="margin-left: 20rpx;font-size: 22rpx;color: #1296DB;">(
可用¥{{userInfo.purchase_funds}}
)</text>
</view>
<view class="icon" @click="onChoosePaytype(18)">
@ -121,33 +135,30 @@
</view>
</view>
</view>
</view>
<view class="m-card order-remark">
<view class="head-title">
<text>订单备注</text>
<text>0/200</text>
</view>
<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="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
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>
<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"
@change="changeAddress" />
<shopListPopupVue ref="shopRef" :show="shopListShow" :list="merchantList" @close="shopListShow = 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>

View File

@ -43,6 +43,7 @@
}
break;
}
uni.vibrateShort();
if (refValue.value.length === props.num) {
emits('complete', refValue.value.join(''));
}

871
utils/push.js Normal file
View File

@ -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