会员中心我的伙伴

This commit is contained in:
zhangmanman
2021-09-26 09:57:34 +08:00
70 changed files with 8653 additions and 435 deletions

View File

@@ -10,6 +10,7 @@ import store from '@/store'
// 基础配置
const config = {
apiUrl : 'http://api.ahxh.shangkelian.cn/api/',
apiUrls : 'http://api.ahxh.shangkelian.cn',
timeout : 60000
}
@@ -154,5 +155,6 @@ const loginHint = () => {
export {
request,
uploading
uploading,
config
}

View File

@@ -69,7 +69,7 @@ const browsers = (page) => {
// 修改用户头像或昵称
const resetUserInfo= (data) => {
return request({
url: 'user/'+data.key,
url: 'user/setting/'+data.key,
method: 'PUT',
data:{
value:data.value

53
apis/interfaces/news.js Normal file
View File

@@ -0,0 +1,53 @@
/**
* Web-zdx
* moduleName: 通知消息列表
*/
import {request} from '../index.js'
// 消息列表
const notificationsType = () => {
return request({
url: 'notifications',
method: 'GET'
})
}
// 根据type 获取具体消息列表
const notificationsList = (type,data) => {
return request({
url: 'notifications/'+type+'/list',
method: 'GET',
data:data
})
}
// 根据type 全部已读
const notificationsReaded = (type) => {
return request({
url: 'notifications/'+type,
method: 'PUT'
})
}
// 根据type 全部已读
const notificationsDelete= () => {
return request({
url: 'notifications',
method: 'DELETE'
})
}
// 根据消息id获取消息详情
const notificationsDetail= (id) => {
return request({
url: 'notifications/'+id,
method: 'get'
})
}
export {
notificationsType,
notificationsList,
notificationsDetail,
notificationsReaded,
notificationsDelete
}

View File

@@ -25,7 +25,7 @@ const wechatbind = (data) => {
// 修改用户头像或昵称
const resetUserInfo = (data) => {
return request({
url: 'user/' + data.key,
url: 'user/setting/' + data.key,
method: 'PUT',
data: {
value: data.value
@@ -71,6 +71,13 @@ const aboutUs = () => {
url: 'articles/about'
})
}
// 获取企业认证状态 -1.未认证0.审核中1.审核通过2.驳回
const companyStatus = () => {
return request({
url: 'companies/applies/query'
})
}
export {
login,
@@ -80,5 +87,6 @@ export {
agreementLogin,
resetUserInfo,
getUserSettingInfo,
aboutUs
aboutUs,
companyStatus
}

159
apis/interfaces/wallet.js Normal file
View File

@@ -0,0 +1,159 @@
/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
* 碌碌无为枉半生,一朝惊醒万事空。
* moduleName: 钱包
*/
import {request} from '../index.js'
// 导出助记词
const seed = () => {
return request({
url: 'chain/safe/seed'
})
}
const hash = (data) => {
return request({
url: 'chain/wallet/hash',
method: 'POST',
data: data
})
}
// 收款码
const code = () => {
return request({
url: 'chain/account/code'
})
}
// 原石余额
const sum = () => {
return request({
url: 'chain/account/balance'
})
}
// 原石价格
const price = () => {
return request({
url: 'nodes/price'
})
}
// 账户记录
const logs = (data) => {
return request({
url: 'chain/account/logs',
data: data
})
}
// 设置安全密码
const security = (data) => {
return request({
url: 'chain/safe/security',
method: 'POST',
data
})
}
// 转账
const transfer = (data) => {
return request({
url: 'chain/account/transfer',
method: 'POST',
data
})
}
// 钱包私钥
const privatekey = (code) => {
return request({
url : "chain/safe/private_key",
data: {
code
}
})
}
// 获取可提现信息
const withdraw = () => {
return request({
url : "withdraw"
})
}
// 提现记录
const withdrawLogs = (data) => {
return request({
url : "withdraw/logs",
data:data
})
}
// 提现
const withdrawDo = (data) => {
return request({
url : "withdraw",
method: 'POST',
data:data
})
}
// 验证支付密码是否正确
const securityCheck = (password) => {
return request({
url : "chain/safe/security/check",
method: 'POST',
data:{
code : password,
}
})
}
// 修改密码
const securityReset = (data) => {
return request({
url : "chain/safe/security",
method: 'PUT',
data:data
})
}
// 提现服务条款
const cmsWithdraw = () => {
return request({
url : "cms/withdraw"
})
}
// 私钥规则
const keyrules = () => {
return request({
url: 'cms/keyrules'
})
}
export {
seed,
hash,
code,
sum,
price,
logs,
security,
transfer,
privatekey,
withdraw,
withdrawLogs,
withdrawDo,
securityCheck,
securityReset,
cmsWithdraw,
keyrules
}

View File

@@ -0,0 +1,72 @@
<template>
<view class="NOList">
<view class="no-addr">
<image :src="`${webUrl}/storage/imageresource/no-image/${name}.png`" mode="widthFix" />
{{txt}}
</view>
</view>
</template>
<script>
import {config} from '@/apis/index.js'
export default {
name: "NOList",
/**
* name 携带过来的图片名称 (与本地问图片文件相对应)
*
* no-address没有地址
* no-counpon没有优惠券
* no-goods没有商品
* no-list没有订单列表
* no-news没有任何消息
* no-new1没有任何消息1
* no-chain (没有区块链信息)
* no-collection没有任何收藏信息
* no-foot (没有足迹信息)
* no-in没有收入信息
* no-out (没有任何支出信息)
* no-order (没有任何订单信息)
* no-order-list (没有任何订单信息)
* no-record (没有任何收益信息)
* no-records 没有任何收益信息2
* no-search (没有任何搜索信息)
* no-shop (没有任何店铺信息)
*
*
* txt 携带过来的提示语
*/
props: {
name: String,
txt: String
},
data() {
return {
webUrl:''
};
},
mounted() {
this.webUrl = config.apiUrls
}
}
</script>
<style lang="scss" scoped>
// 无地址
.no-addr {
padding-top: $padding*4;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
box-sizing: border-box;
color: #999;
font-size: $title-size*0.9;
image {
margin-bottom: $margin*2;
margin-top: $margin*1;
width: 400rpx;
opacity: .4;
}
}
</style>

View File

@@ -0,0 +1,238 @@
<template>
<view class="numberJpan" :style="wc" v-show="flag" >
<!-- <view class="myshuru" :style="obj" @tap.stop="flag=true">
<view class="srk" :style="'width:'+100/(length||6)+'%'" v-for=" i in length||6" :id="(i-1)==xz?'numberJpanActive':''" >
{{arr[i-1]}}
</view>
</view> -->
<view class="myshuru" :style="obj" @tap.stop="flag=true">
<view class="gb" @tap="close()" :style="gsbstyle">×</view>
<view class="shuruTitle">
请输入支付密码
</view>
<view class="center-x">
<view class="srk" :style="'width:'+100/(length||6)+'%'" v-for=" i in length||6" :id="(i-1)==xz?'numberJpanActive':''" :key="i" >
<!-- #ifdef MP-WEIXIN -->
{{showNum?arr[i]==null?'':arr[i]:arr[i]!=null?"●" : ""}}
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
{{showNum?arr[i-1]==null?'':arr[i-1]:arr[i-1]!=null?"●" : ""}}
<!-- #endif -->
</view>
</view>
</view>
<view class="jpan" :style="tsfY">
<view class="nav" @tap="close()">
<uni-icons type="arrowdown"></uni-icons>
</view>
<view class="main">
<!-- #ifdef MP-WEIXIN -->
<view v-for="i in 9" :key="i" @tap="numshuzi(i+1)">{{i+1}}</view>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<view v-for="i in 9" :key="i" @tap="numshuzi(i)">{{i}}</view>
<!-- #endif -->
<view> </view>
<view @tap="numshuzi(0)">0</view>
<view @tap="del()">
<uni-icons type="arrowthinleft"></uni-icons>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name:'number-jpan',
data() {
return {
wc:{
'background-color':"rgba(0, 0, 0, .0)"
},
obj:{
"opacity":0,
"top":'50%'
},
flag:false,
clear1:"",
clear2:"",
arr:[],
xz:0,
gsbstyle:{
"opacity":0
},
tsfY:{
'transform':'translateY(100%)'
}
};
},
props:['length','showNum'],
methods:{
del(){
if(this.xz>0){
//let arr1=this.arr
//arr1[this.xz]=""
//this.arr=arr1
this.arr.pop();
this.xz--;
}
uni.vibrateShort();
},
numshuzi(num){
let arr1=this.arr
arr1[this.xz]=num
this.arr=arr1
uni.vibrateShort();
this.xz++
if(this.xz==this.length){
let str=""
for(let item of this.arr){
str+=item
}
this.$emit('closeChange',str)
this.close()
}
},
open(){
this.flag=true;
this.arr=[];
this.xz=0;
this.clear1=setTimeout(()=>{
this.wc='background-color:rgba(0, 0, 0, .5)';
this.obj='opacity:1;top:40%';
this.gsbstyle="opacity:1";
this.tsfY='transform:translateY(0%)';
},100)
},
close(){
this.wc={
'background-color':"rgba(0, 0, 0, .0)"
}
this.obj={
"opacity":0,
"top":'50%'
}
this.gsbstyle={
"opacity":0
}
this.clear2=setTimeout(()=>{
this.flag=false
},1000)
this.tsfY={
'transform':'translateY(100%)'
}
},
xuanze(i){
this.xz=i
uni.vibrateShort();
}
}
}
</script>
<style lang="scss">
#numberJpanActive{
background-color: $mian-color;
color: #FFFFFF;
}
.jpan{
width: 100vw;
height: 30vh;
background-color: #FFFFFF;
position: absolute;
bottom: 0;
transform: translateY(100%);
transition: all .5s;
.nav{
text-align: center;
line-height: 50upx;
box-sizing: border-box;
border-bottom: 1px solid #EEEEEE;
}
.main{
width: 100%;
height: calc(30vh - 50upx);
view{
box-sizing: border-box;
float: left;
width: 33.33%;
height: 25%;
font-size: 40upx;
text-align: center;
line-height:7.5vh;
border: 1px solid #f4f4f4;
}
view:active{
background-color: #EEEEEE;
}
}
}
.numberJpan{
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0);
transition: all .5s;
z-index: 999;
.myshuru{
transition: all .5s;
position: absolute;
width: 70vw;
height: 350upx;
top: 50%;
opacity: 0;
transform: translate(-50%,-50%);
background-color: #FFFFFF;
left: 50%;
color: #000000;
border-radius: 20upx;
overflow: hidden;
.shuruTitle{
margin: 100upx auto;
font-weight: 900;
text-align: center;
font-size: 30upx;
}
.center-x{
width: 90%;
height: 80upx;
border: 1px solid #EEEEEE;
border-radius: 20upx;
position: absolute;
overflow: hidden;
left: 50%;
transform: translateX(-50%);
bottom: 50upx;
.srk{
height: 100%;
line-height: 80upx;
text-align: center;
float: left;
box-sizing: border-box;
border-left: 1px solid #EEEEEE;
transition: all .4s;
}
.srk:nth-child(1){
border-left:0px;
border-radius: 20upx 0 0 20upx;
}
}
}
}
.gb{
position: absolute;
font-size: 50upx;
top: 0;
color: #AAAAAA;
left: 30upx;
transition: all .5s;
}
</style>

View File

@@ -0,0 +1,93 @@
<template>
<view>
<block v-if="list.length > 0">
<view class="record--item" v-for="(item, index) in list" :key="index">
<view class="title ellipsis">{{item.hash || '-'}}</view>
<view class="time ellipsis">{{item.block_time || '-'}}</view>
<view class="webkit-box variation">
<view class="ellipsis" :class="item.is_in ? 'add': 'remove'">{{item.is_in ? '+': '-'}}{{item.amount}}</view>
<view class="symbol">{{item.assets.symbol}}</view>
</view>
</view>
</block>
<block v-else>
<no-list v-if='logsType === 0' name='no-record' txt="没有任何记录~" />
<no-list v-if='logsType === 2' name='no-in' txt="没有任何收入记录~" />
<no-list v-if='logsType === 1' name='no-out' txt="没有任何支出记录~" />
</block>
</view>
</template>
<script>
export default {
name:"property",
props:{
list: {
type: Array,
default: () => {
return []
}
},
logsType:{
type:Number
}
},
data() {
return {
};
}
}
</script>
<style lang="scss" scoped>
.record--item{
padding: $padding 320rpx $padding 0;
border-bottom: solid 1rpx $border-color;
position: relative;
min-height: 50rpx;
.variation{
position: absolute;
right: 0;
top: $margin;
bottom: $margin;
width: 300rpx;
text-align: right;
font-weight: bold;
&>label{
font-size: 80%;
}
.symbol{
color: $mian-color;
font-weight: normal;
font-size: $title-size-m;
}
.add{
color: $mian-color;
}
.remove{
color: $mian-color;
}
}
.title{
line-height: 50rpx;
}
.time{
font-size: $title-size-m;
color: $mian-color;
}
}
// 数据空
.record--null{
padding-top: $padding * 3;
text-align: center;
color: $mian-color;
font-size: $title-size;
height: 50vh;
box-sizing: border-box;
line-height: 60rpx;
image{
width: 168rpx;
}
}
</style>

View File

@@ -4,7 +4,8 @@ import App from './App'
import Vue from 'vue'
import { router, RouterMount } from './router'
import store from './store'
import uView from 'uview-ui'
import uView from 'uview-ui'
import noList from './components/no-list-components/index.vue'
Vue.use(router)
Vue.use(uView);
Vue.config.productionTip = false
@@ -12,7 +13,8 @@ Vue.prototype.$store = store
App.mpType = 'app'
const app = new Vue({
...App
})
})
Vue.component('no-list',noList)
// #ifdef H5
RouterMount(app,router,'#app')
// #endif

View File

@@ -149,6 +149,104 @@
"style": {
"navigationBarTitleText": "企业认证"
}
}, {
"path": "pages/news/index",
"name": "news",
"auth": true,
"style": {
"navigationBarTitleText": "消息中心"
}
}, {
"path": "pages/news/detail",
"name": "newsDetail",
"auth": true,
"style": {
"navigationBarTitleText": "消息列表"
}
}, {
"path": "pages/wallet/property",
"name": "walletProperty",
"style": {
"navigationBarTitleText": "能量钱包",
"enablePullDownRefresh": false,
"navigationBarTextStyle": "white"
}
}, {
"path": "pages/wallet/extract",
"style": {
"navigationBarTitleText": "提现能量",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#774ffd",
"navigationBarTextStyle": "white"
},
"name": "Extract"
}, {
"path": "pages/wallet/resetPassword",
"style": {
"navigationBarTitleText": "重置密码",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#774ffd",
"navigationBarTextStyle": "white"
},
"name": "ResetPassword"
},{
"path": "pages/verification/index",
"name": "verificationIndex",
"auth": true,
"style": {
"navigationBarTitleText": "扫码核销"
}
},{
"path": "pages/verification/history",
"name": "verificationHistory",
"auth": true,
"style": {
"navigationBarTitleText": "核销记录"
}
},{
"path": "pages/shop/lists",
"name": "shopLists",
"auth": true,
"style": {
"navigationBarTitleText": "部门/门店"
}
},{
"path": "pages/shop/create",
"name": "shopCreate",
"auth": true,
"style": {
"navigationBarTitleText": "创建部门/门店"
}
},{
"path": "pages/employees/list",
"name": "employeesList",
"auth": true,
"style": {
"navigationBarTitleText": "员工管理"
}
},{
"path": "pages/employees/add",
"name": "employeesAdd",
"auth": true,
"style": {
"navigationBarTitleText": "添加员工"
}
},{
"path": "pages/instrument/Spread",
"name": "instrumentSpread",
"auth": true,
"style": {
"navigationBarTitleText": "营销推广码"
}
}, {
"path": "pages/wallet/fragment",
"style": {
"navigationBarTitleText": "能量碎片记录",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#774ffd",
"navigationBarTextStyle": "white"
},
"name": "Fragment"
}],
"globalStyle": {
"navigationStyle": "custom",
@@ -181,4 +279,4 @@
"easycom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
}
}
}

311
pages/employees/add.vue Normal file
View File

@@ -0,0 +1,311 @@
<template>
<view class="content" v-if="!loging">
<!-- 基础信息 -->
<view class="info-card">
<view class="cover">
<view class="cover-add vertical" @click="updCover">
<block v-if="cover.showpath != ''">
<image :src="cover.showpath" mode="aspectFill"></image>
</block>
<block v-else>
<image class="cover-default" src="@/static/icons/add-icon.png" mode="widthFix"></image>
<view>员工寸照</view>
</block>
</view>
</view>
<view class="info-text">
<view class="info-inputs">
<input type="text" v-model="name" placeholder="姓名"/>
</view>
<view class="info-inputs">
<input type="number" v-model="phone" placeholder="手机号码"/>
</view>
<view class="info-inputs">
<input type="text" v-model="job" placeholder="职业"/>
</view>
<view class="info-inputs">
<picker :range="section" range-key="name" :value="sectionIndex" @change="pickerChange">
<view class="picker-text">
{{section[sectionIndex].name}}
<uni-icons class="icon" type="arrowdown" color="#555"></uni-icons>
</view>
</picker>
</view>
</view>
</view>
<view class="jurisdiction switch">
<view class="item">
<label>
<view class="item-title">设为推荐</view>
<view class="item-info">设为推荐员工将在企业自媒体中优先展示</view>
<switch class="item-switch" :checked="isPosition" color="#e93340" @change="switchChange" />
</label>
</view>
</view>
<!-- 权限设置 -->
<view class="title">权限设置</view>
<view class="jurisdiction">
<checkbox-group @change="permissionChange">
<view class="item" v-for="(item, index) in permissions" :key="index">
<label>
<view class="item-title">{{item.title}}</view>
<view class="item-info">{{item.description}}</view>
<checkbox class="item-checkbox" :checked="item.check" color="#e93340" :value="item.permission_id" />
</label>
</view>
</checkbox-group>
</view>
<!-- 按钮 -->
<view class="add-btns">
<button size="default" @click="onAddEmployees">{{type === 'PUT' ? '修改': '添加'}}</button>
</view>
</view>
</template>
<script>
import { employeesConfig, addEmployees, employeesInfo, employeesPut } from '@/apis/interfaces/employees'
import { uploads } from '@/apis/interfaces/uploading'
export default {
data() {
return {
type : '',
loging : true,
section : [],
permissions : [],
permissionIds: [],
sectionIndex : 0,
cover : {
showpath : '',
path : ''
},
name : '',
phone : '',
job : '',
isPosition : false
};
},
created() {
if(this.$Route.query.type === 'PUT'){
this.type = 'PUT'
uni.setNavigationBarTitle({
title: '编辑员工'
})
}
employeesConfig().then(res => {
this.section = res.store
if(this.$Route.query.type === 'PUT'){
employeesInfo(this.$Route.query.id || 4).then(res => {
let permissionIds = []
for(let val of res.permission){
if(val.check){
permissionIds.push(val.permission_id)
}
}
this.permissions = res.permission
this.sectionIndex = this.section.findIndex(val => val.store_id == res.store.store_id)
this.permissionIds= permissionIds
this.name = res.name
this.phone = res.mobile
this.job = res.job
this.cover = res.cover
this.isPosition = res.is_position
this.loging = false
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
}else{
this.permissions = res.permissions
this.loging = false
}
})
},
methods:{
// 设为推荐
switchChange(e){
this.isPosition = e.detail.value
},
// 选择部门
pickerChange(e){
this.sectionIndex = e.detail.value
},
// 权限选择
permissionChange(e){
this.permissionIds = e.detail.value
},
// 上传照片
updCover(){
uni.chooseImage({
crop: {width: 229, height: 320},
success: path=> {
uploads([{
uri : path.tempFilePaths[0]
}]).then(res => {
this.cover = {
showpath: res.url[0],
path : res.path[0]
}
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
}
})
},
// 添加员工
onAddEmployees(){
let data = {
name : this.name,
mobileNo : this.phone,
job : this.job,
cover : this.cover.path,
position : this.isPosition ? 1: 0,
order : 0,
store_id : this.section[this.sectionIndex].store_id,
permission : this.permissionIds
}
let submitAdd = this.type == 'PUT' ? employeesPut(this.$Route.query.id, data) : addEmployees(data)
submitAdd.then(res => {
uni.showModal({
title : '提示',
content : res,
showCancel : false,
success : () => {
this.$Router.back()
}
})
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
}
}
}
</script>
<style lang="scss" scoped>
.content{
min-height: 100vh;
@extend .ios-bottom;
.title{
padding: ($padding/2) $padding;
color: $text-gray;
}
.jurisdiction{
background: white;
&.switch{
margin-top: $margin;
}
.item{
position: relative;
padding: $padding 150rpx $padding $padding;
&::after{
position: absolute;
left: $padding;
right: 0;
bottom: 0;
height: 1rpx;
content: " ";
background: $border-color;
}
&:last-child::after{
display: none;
}
.item-checkbox{
position: absolute;
right: $padding;
top: 50%;
height: 40rpx;
margin-top: -27rpx;
}
.item-switch{
position: absolute;
right: $padding;
top: 50%;
height: 40rpx;
margin-top: -27rpx;
}
.item-title{
font-size: $title-size;
padding-bottom: $margin/3;
}
.item-info{
font-size: $title-size-m;
color: $text-gray;
}
}
}
// 基础信息
.info-card{
background: white;
padding: $padding;
position: relative;
min-height: 238rpx;
.cover{
position: absolute;
top: $padding;
left: $padding;
background: #f8f8f8;
width: 229rpx;
height: 320rpx;
.cover-add{
position: absolute;
width: 100%;
height: 100%;
text-align: center;
image{
width: 229rpx;
height: 320rpx;
}
image.cover-default{
width: 128rpx;
}
color: $text-gray-m;
font-size: $title-size-m;
}
}
.info-text{
padding-left: $padding + 229;
.info-inputs{
height: 80rpx;
line-height: 80rpx;
border-bottom: solid 1rpx $border-color;
input{
height: 80rpx;
}
.picker-text{
position: relative;
padding-right: 80rpx;
.icon{
position: absolute;
right: 0;
top: 0;
}
}
}
}
}
// 添加按钮
.add-btns{
padding: $padding;
button[size='default']{
height: 90rpx;
line-height: 90rpx;
padding: 0;
margin: 0;
background: $text-price;
font-size: $title-size;
font-weight: bold;
color: white;
border-radius: 0;
}
}
}
</style>

260
pages/employees/list.vue Normal file
View File

@@ -0,0 +1,260 @@
<template>
<view class="ios-bottom" v-if="!loding">
<view class="header-flex">
员工数量 {{total}}
<view class="add-btn" @click="addEmployees">添加员工</view>
</view>
<!-- 员工列表 -->
<uni-collapse v-if="lists.length > 0">
<block v-for="(listItem, listIndex) in lists" :key="listIndex">
<uni-collapse-item :show-animation="true" :open="listIndex === 0">
<template v-slot:title>
<view class="collapse-title">{{listItem.name}}</view>
</template>
<block v-if="listItem.data.length > 0">
<view class="employees-border" v-for="(item, index) in listItem.data" :key="index">
<uni-swipe-action>
<uni-swipe-action-item :rightOptions="options" @click="onEmployees($event, listIndex, index)">
<view class="employees-item">
<view class="cover">
<block v-if="item.user.avatar === ''">{{item.name.slice(0,1)}}</block>
<block v-else>
<image class="cover-img" :src="item.user.avatar" mode="aspectFill"></image>
</block>
</view>
<view class="content">
<view class="nickname nowrap">{{item.name}}<text>{{item.job}}</text></view>
<view class="job nowrap">
<text v-for="(permissionItem, permissionIndex) in item.permission" :key="permissionIndex">{{permissionItem}}</text>
</view>
</view>
</view>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
</block>
<block v-else>
<view class="employees-null">店铺暂无员工</view>
</block>
</uni-collapse-item>
</block>
</uni-collapse>
<view v-else class="list-null">
<image class="icon" src="@/static/icons/listnull-icon.png" mode="widthFix" />
<view class="sub-title">暂未添加员工</view>
<view class="sub-btn" @click="$Router.push({name: 'employeesAdd'})">添加员工</view>
</view>
</view>
</template>
<script>
import { employees, employeesDelete } from '@/apis/interfaces/employees'
export default {
data() {
return {
loding : true,
lists : [],
total : 0,
options : [{
text : '编辑',
type : 'PUT',
style : {
backgroundColor: '#3688ee'
}
},{
text : '删除',
type : 'DELETE',
style : {
backgroundColor: '#e93340'
}
}]
};
},
onShow(){
employees().then(res => {
this.lists = res.data
this.total = res.total
this.loding = false
})
},
methods:{
// 编辑,删除
onEmployees(e, upIndex, index){
let type = e.content.type,
val = this.lists[upIndex].data[index]
if(type == 'PUT'){
this.$Router.push({name: 'addEmployees', params: {type: 'PUT', id: val.employee_id}})
return
}
uni.showModal({
title : '提示',
content : '删除后无法恢复,确定删除员工[' + val.name + ']吗?',
cancelText : '取消',
cancelColor : '#555',
confirmText : '确认',
confirmColor: '#e93340',
success : res => {
if(res.confirm) {
employeesDelete(val.employee_id).then(res => {
uni.showToast({
title: res,
icon : 'none'
})
this.lists[upIndex].data.splice(index, 1)
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
}
}
})
},
// 添加员工
addEmployees(){
if(this.lists.length <= 0){
uni.showModal({
title : '提示',
content : '暂未创建门店,无法添加员工',
cancelText : '稍后创建',
cancelColor : '#555',
confirmText : '立即创建',
confirmColor: '#e93340',
success : res => {
if(res.confirm) {
this.$Router.push({name: 'shopCreate'})
}
}
})
return
}
this.$Router.push({name: 'employeesAdd'})
}
}
};
</script>
<style lang="scss" scoped>
.collapse-title{
padding: 0 $padding;
line-height: 90rpx;
font-weight: bold;
font-size: $title-size-lg;
}
.employees-item {
background: white;
padding: ($padding - 10) $padding;
position: relative;
&::before {
position: absolute;
bottom: 0;
left: $padding + 98;
right: 0;
content: ' ';
height: 1rpx;
background: $border-color;
}
.cover {
position: absolute;
top: $padding - 10;
left: $padding;
background: $text-price;
color: white;
height: 88rpx;
width: 88rpx;
line-height: 88rpx;
text-align: center;
border-radius: 50%;
overflow: hidden;
font-size: $title-size-lg;
.cover-img {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
}
.content {
height: 88rpx;
padding-left: 108rpx;
.nickname{
line-height: 40rpx;
font-size: $title-size;
padding-bottom: 10rpx;
text{
font-size: $title-size-sm;
color: $text-gray-m;
padding-left: 10rpx;
}
}
.job{
line-height: 38rpx;
text{
background-color: $border-color-lg;
color: $text-gray;
padding: 0 10rpx;
line-height: 38rpx;
margin-left: $margin/2;
display: inline-block;
&:first-child{
margin-left: 0;
}
}
}
}
}
// 空提示
.list-null{
width: 100vw;
height: 100vh;
box-sizing: border-box;
text-align: center;
background: white;
padding-bottom: 20vh;
@extend .vertical;
.sub-title{
color: $text-gray;
font-size: $title-size-m;
}
.icon{
width: 288rpx;
}
.sub-btn{
width: 200rpx;
height: 70rpx;
line-height: 70rpx;
text-align: center;
background: $mian-color;
color: white;
display: inline-block;
margin-top: $margin*2;
}
}
.employees-null{
text-align: center;
line-height: 10vh;
padding-bottom: $padding;
font-size: $title-size-m;
color: $text-gray;
}
// 添加员工header
.header-flex{
background: white;
padding: ($padding/2) $padding;
display: flex;
justify-content: space-between;
margin-bottom: $margin - 10;
line-height: 60rpx;
color: $text-gray;
.add-btn{
background: $mian-color;
color: white;
width: 150rpx;
text-align: center;
font-size: $title-size-m;
}
}
</style>

View File

@@ -1,51 +1,60 @@
<template>
<view class="content">
<!-- 水晶获得公告 -->
<view class="notice" v-if="notice.length >= 1">
<swiper class="notice-swiper" :vertical="true" autoplay circular>
<swiper-item v-for="(item, index) in notice" :key="index">
<view class="notice-item">
<image class="notice-cover" :src="item.avatar" mode="aspectFill"></image>
<view class="notice-title ellipsis">{{item.nickname}} {{item.title}} {{item.amount}}</view>
</view>
</swiper-item>
</swiper>
</view>
<!-- 账户余额 -->
<view class="info">
<view class="info-number">
<image class="number-background number-rotate" src="@/static/background/chain-back-01.png" />
<view class="info-content webkit-box">
<view class="text">{{isAuth ? '持有原石量': '恒量发行原石量'}}<uni-icons class="help-icon" @click="showHelp('occ')" type="help-filled" size="18" color="#fff" /></view>
<view class="number">{{occ}}</view>
<view class="login" @click="$Router.push({name: 'Login'})" v-if="!isAuth">立即登录</view>
<view class="login" @click="openWallet" v-else>我的钱包</view>
<view class="total">
<view class="item nowrap"><image src="@/static/icons/gemstone-icon.png"/>能量球 99</view>
<view class="item nowrap"><image src="@/static/icons/crystal-icon.png"/>能量碎片 11</view>
</view>
<!-- 矿机 -->
<view class="ore">
<image class="ore-back" src="@/static/background/chain-back-00.png" mode="widthFix"></image>
<view class="ball">
<view class="shadow"></view>
</view>
<view class="ore-lists">
<view class="oct-float ore-item" v-for="(item, index) in crystalArr" :key="index" @click="ledCrystal(index)">
<block v-if="item.amount !== null">
<image src="/static/imgs/crystal-ore-icon.png" mode="widthFix" class="icon" />
<view class="text">能量碎片{{ item.amount || '-'}}</view>
</block>
</view>
<navigator url="../index/index" open-type="switchTab" hover-class="none" class="oct-float ore-item-nav">
<image src="/static/imgs/gemstone-ore-icon.png" mode="widthFix" class="icon" />
<view class="text">购物<uni-icons type="arrowright" color="#FFFFFF" size="14"></uni-icons></view>
</navigator>
</view>
</view>
<!-- 公告信息 -->
<!-- <view class="increase">今日消费100元预计原石单价增长0.1%</view> -->
<!-- 任务分类 -->
<scroll-view class="task-block" scroll-x="true">
<view class="item" v-for="(item, index) in categoryArr" :key="index" @click="JumpUrl(item.url, item.title)">
<view class="text">{{ item.remark }}</view>
<view class="icon">
<image :src="item.cover" />
</view>
<view class="title">{{ item.title }}</view>
</view>
</scroll-view>
<!-- 平台概况 -->
<view class="situation">
<view class="header">
<view class="header-item">
<view class="title">平台原石余量<uni-icons class="help-icon" @click="showHelp('occBalance')" type="help-filled" size="18" color="#009b69" /></view>
<view class="title">平台原石余量<uni-icons class="help-icon" @click="showHelp('occBalance')" type="help-filled" size="18" color="rgba(255,255,255,.3)" /></view>
<view class="number ellipsis">{{ occBalance }}</view>
</view>
<view class="header-item">
<view class="title">昨日瓜分水晶<uni-icons class="help-icon" @click="showHelp('yesterdayCrystal')" type="help-filled" size="18" color="#009b69" /></view>
<view class="title">昨日瓜分水晶<uni-icons class="help-icon" @click="showHelp('yesterdayCrystal')" type="help-filled" size="18" color="rgba(255,255,255,.3)" /></view>
<view class="number ellipsis">{{ yesterdayCrystal }}</view>
</view>
<view class="header-item">
<view class="title">区块链高度<uni-icons class="help-icon" @click="showHelp('blockHeight')" type="help-filled" size="18" color="#009b69" /></view>
<view class="title">区块链高度<uni-icons class="help-icon" @click="showHelp('blockHeight')" type="help-filled" size="18" color="rgba(255,255,255,.3)" /></view>
<view class="number ellipsis">{{ blockHeight }}</view>
</view>
<view class="header-item">
<view class="title">平台累计盈利额<uni-icons class="help-icon" @click="showHelp('gain')" type="help-filled" size="18" color="#009b69" /></view>
<view class="title">平台累计盈利额<uni-icons class="help-icon" @click="showHelp('gain')" type="help-filled" size="18" color="rgba(255,255,255,.3)" /></view>
<view class="number ellipsis">{{ gain }}</view>
</view>
<view class="header-item">
<view class="title">已开通节点数<uni-icons class="help-icon" @click="showHelp('nodeNumber')" type="help-filled" size="18" color="#009b69" /></view>
<view class="title">已开通节点数<uni-icons class="help-icon" @click="showHelp('nodeNumber')" type="help-filled" size="18" color="rgba(255,255,255,.3)" /></view>
<view class="number ellipsis">{{ nodeNumber }}</view>
</view>
</view>
@@ -93,11 +102,10 @@
import F2 from '@/uni_modules/lime-f2/components/lime-f2/f2.min.js'
import lF2 from '@/uni_modules/lime-f2/components/lime-f2/'
export default {
components: {
lF2
},
data() {
return {
crystalArr : [],
categoryArr : [],
occs: {},
blockHeight: 0,
occBalance: 0,
@@ -125,8 +133,8 @@
// 求助信息
showHelp(type) {
uni.showModal({
title: '提示',
content: this.helpToast[type],
title: '提示',
content: this.helpToast[type],
showCancel: false
})
},
@@ -179,6 +187,7 @@
// occ信息
getOcc(){
occ().then(res => {
console.log(res)
this.occs = res.occs
this.yesterdayCrystal = res.yesterday_crystal
this.occ = res.occ
@@ -190,7 +199,10 @@
if(res.help_toast) this.helpToast = res.help_toast
this.showCartc(res.movements)
}).catch(err => {
console.log(err)
uni.showToast({
title: err.message,
icon : 'none'
})
})
},
// 绘制图表
@@ -264,154 +276,100 @@
</script>
<style scoped>
/* 气泡漂浮 */
.number-float{
/* 星球旋转 */
.ball{
position: absolute;
height: 480rpx;
width: 480rpx;
top: 50%;
left: 50%;
margin-top: -240rpx;
margin-left: -240rpx;
border-radius: 50%;
-webkit-transform-style: preserve-3d;
background: url(/static/background/chain-back-02.png) repeat-x;
background-size: auto 100%;
-webkit-animation: move-map 30s infinite linear;
-moz-animation: move-map 30s infinite linear;
-o-animation: move-map 30s infinite linear;
-ms-animation: move-map 30s infinite linear;
animation: move-map 30s infinite linear;
box-shadow: 0 0 50rpx 50rpx rgba(31,25,34, .2);
}
.shadow{
position: absolute;
top: 1%;
left: 5%;
width: 90%;
height: 90%;
border-radius: 50%;
filter: blur(5px);
z-index: 3;
background: radial-gradient(circle at 50% 0, rgba(255,255,255, .6) , rgba(255, 255, 255, .0) 58%);
}
.ball:before,
.ball::after{
position: absolute;
top: 0;
left: 0;
content: "";
width: 100%;
height: 100%;
border-radius: 50%;
filter: blur(5px);
z-index: 2;
}
.ball:before {
background: radial-gradient(circle at 100% 50%, #5881d3 , rgba(255, 255, 255, .0) 45%);
}
.ball::after {
background: radial-gradient(circle at 0 50%, #ca66e0 , rgba(255, 255, 255, .0) 45%);
}
@-webkit-keyframes move-map {
0% {background-position: -1250rpx 0; }
100% {background-position: 0 0;}
}
@-ms-keyframes move-map {
0% {background-position: -1250rpx 0; }
100% {background-position: 0 0;}
}
@keyframes move-map {
0% {background-position: -1250rpx 0; }
100% {background-position: 0 0;}
}
/* 水晶漂浮动画 */
.oct-float {
animation: 4s octfloat infinite;
}
@keyframes octfloat{
0%{
@keyframes octfloat {
0% {
margin-top: 0;
}
50%{
50% {
margin-top: 15rpx;
}
100%{
100% {
margin-top: 0;
}
}
/* 背景旋转 */
.number-rotate{
animation: 30s octrotate infinite linear;
}
@keyframes octrotate{
from{
transform:rotate(0deg);
}
to{
transform:rotate(360deg);
}
}
</style>
<style lang="scss">
// 背景
<style lang="scss" scoped>
.content{
background: $mian-color-deep;
min-height: 100vh;
padding-top: var(--status-bar-height);
box-sizing: border-box;
background-image: url(@/static/background/chain-back-00.png);
background-size: 100%;
background-position: top center;
background-repeat: no-repeat;
}
// 求助icon
.help-icon{
vertical-align: middle;
margin-bottom: 4px;
margin-left: $margin/2;
opacity: .7;
}
// 原石账户
.info{
margin-top: calc(#{$margin * 2} + 60rpx);
padding: var(--status-bar-height) $padding * 2 $padding * 3;
text-align: center;
.info-number{
position: relative;
display: inline-block;
width: 568rpx;
height: 568rpx;
.number-background{
width: 100%;
height: 100%;
}
.info-content{
position: absolute;
top: 12%;
left: 12%;
width: 76%;
height: 76%;
background-image: url(@/static/background/chain-back-02.png);
background-size: cover;
color: white;
.text{
font-size: $title-size-m;
text-shadow: 2rpx 2rpx 0 rgba($color: $mian-color-deep, $alpha: .5);
}
.number{
font-weight: bold;
font-size: $title-size + 8;
line-height: 70rpx;
text-shadow: 2rpx 2rpx 0 rgba($color: $mian-color-deep, $alpha: .5);
}
.login{
margin-top: $margin;
background-color: $mian-color;
display: inline-block;
padding: ( $padding / 2 ) $padding;
font-size: $title-size-m;
border-radius: 30rpx;
border:solid 1rpx $mian-color-deep;
}
}
}
}
// 预计增长
.increase{
margin: 0 ($margin + $margin / 2) ($margin * 2);
background: rgba($color: $mian-color, $alpha: .1);
text-align: center;
height: 80rpx;
line-height: 80rpx;
font-size: $title-size-m;
color: $mian-color;
border-radius: $radius-sm;
padding: 0 $padding;
}
// 公告信息
.notice{
position: fixed;
top: $margin * 2;
left: $margin + $margin / 2;
right: $margin + $margin / 2;
padding-top: var(--status-bar-height);
z-index: 99;
.notice-swiper{
height: 60rpx;
}
.notice-item{
position: relative;
height: 60rpx;
padding-left: 80rpx;
padding-right: $padding * 2;
display: inline-block;
background: rgba($color: $mian-color-deep, $alpha: .3);
border-radius: 30rpx;
box-sizing: border-box;
max-width: 100%;
.notice-cover{
position: absolute;
height: 60rpx;
width: 60rpx;
left: 0;
top: 0;
background-color: $mian-color-deep;
border-radius: 50%;
}
.notice-title{
line-height: 60rpx;
color: white;
font-size: $title-size-m;
}
}
min-height: calc(100vh - 60px);
background: #1f1922;
overflow: hidden;
}
// 平台概况
.situation{
margin: 0 ($margin + $margin / 2);
background-image: linear-gradient(to bottom, rgba($color: $mian-color, $alpha: .1), $mian-color-deep);
border-radius: $radius-sm;
padding: $padding;
margin: 0 $margin;
background-image: linear-gradient(to bottom, $block-color, #1f1922);
border-radius: $radius;
padding: $padding $padding/2 $padding*2;
// 平台统计
.header{
display: flex;
@@ -419,23 +377,22 @@
margin-bottom: $margin*2;
.number{
color: white;
font-size: $title-size + 4;
font-size: $title-size;
padding-top: $padding/2;
font-weight: bold;
line-height: 90rpx;
}
.title{
color: $mian-color;
font-weight: bold;
color: rgba($color: white, $alpha: .4);
font-size: $title-size-sm;
}
.header-item{
width: 50%;
padding: $padding $padding / 2;
padding: $padding / 2;
box-sizing: border-box;
&:first-child{
width: 100%;
.number{
font-size: $title-size + 10;
font-size: $title-size;
}
}
}
@@ -446,12 +403,12 @@
flex-wrap: wrap;
margin: 0 -$margin / 2;
.node-item{
background: rgba($color: $mian-color, $alpha: .2);
background: rgba($color: $block-color, $alpha: .8);
width: calc(50% - #{$margin});
margin: $margin / 2;
padding: $padding;
box-sizing: border-box;
border-radius: $radius-sm;
border-radius: $radius/2;
}
.number{
font-size: $title-size + 4;
@@ -459,21 +416,20 @@
color: white;
}
.title{
font-size: $title-size-m;
font-weight: bold;
color: rgba($color: white, $alpha: .7);
font-size: $title-size-sm;
color: white;
}
}
// 图表
.chart{
background: rgba($color: $mian-color, $alpha: .2);
background: rgba($color: $block-color, $alpha: .8);
padding: $padding;
border-radius: $radius-sm;
margin-top: $margin*2;
border-radius: $radius/2;
margin-top: $margin;
.title{
text-align: center;
line-height: 80rpx;
color: rgba($color: $mian-color, $alpha: 1.0);
color: white;
font-size: $title-size-m;
}
.chart-f2{
@@ -481,4 +437,137 @@
}
}
}
// 数据统计
.total {
position: relative;
margin: $margin;
background: #2b2449;
padding: 0;
display: flex;
border-radius: $radius;
.item {
width: 50%;
padding: 0 $padding;
text-align: center;
color: white;
font-size: $title-size-sm;
line-height: 76rpx;
image{
width: 38rpx;
height: 38rpx;
vertical-align: top;
margin-top: calc((76rpx - 38rpx) / 2);
margin-right: $margin / 2;
}
}
&::before {
position: absolute;
top: 0;
bottom: 0;
content: "";
width: 2rpx;
left: 50%;
background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, .7), transparent);
}
}
// 求助icon
.help-icon{
vertical-align: middle;
margin-left: $margin/3;
opacity: .7;
}
// 矿石
.ore {
position: relative;
padding-top: 120%;
&>image {
width: 100%;
position: absolute;
top: 0;
left: 0;
}
.ore-lists {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
.oct-float-item{
position: absolute;
text-align: center;
.text {
margin-top: $margin / 2;
color: white;
font-size: $title-size-sm;
line-height: 40rpx;
text-shadow: 0 3rpx 3rpx rgba($color: #000000, $alpha: .2);
}
.icon {
width: 58rpx;
vertical-align: top;
}
}
.ore-item-nav{
@extend .oct-float-item;
right: $margin * 3;
top: 12%;
}
.ore-item {
@extend .oct-float-item;
&:nth-child(1) { top: 16%; left: 13%; }
&:nth-child(2) { top: 50%; right: 10%; }
&:nth-child(3) { top: 23%; right: 20%; }
&:nth-child(4) { top: 70%; left: 33%;}
&:nth-child(5) { top: 40%; left: 20%; }
&:nth-child(6) { top: 58%; left: 10%;}
&:nth-child(7) { top: 10%; right: 43%;}
&:nth-child(8) { top: 46%; right: 29%;}
}
}
}
// 任务
.task-block {
white-space: nowrap;
.item {
background: rgba($color: $mian-color, $alpha: .2);
display: inline-block;
margin-left: $margin;
width: 210rpx;
padding: $padding * 2 $padding;
border-radius: $radius;
box-sizing: 0 0 4rpx 4rpx rgba($color: #000000, $alpha: .06);
text-align: center;
&:first-child {
margin-left: $margin + $margin/2;
}
&:last-child {
margin-right: $margin + $margin/2;
}
.icon {
display: inline-block;
margin: $margin 0;
width: 98rpx;
height: 98rpx;
line-height: 98rpx;
background: $mian-color-deep;
border-radius: 50%;
text-align: center;
image {
width: 56rpx;
height: 56rpx;
vertical-align: middle;
}
}
.text {
font-size: $title-size-m;
color: $mian-color;
}
.title {
font-size: $title-size;
color: white;
font-weight: bold;
}
}
}
</style>

249
pages/instrument/Spread.vue Normal file
View File

@@ -0,0 +1,249 @@
<template>
<view class="content">
<view class="codeContent">
<image class="codeContent-back" src="../../static/icons/store_codeBack.png" mode="widthFix"></image>
<image class="codeContent-cont" src="../../static/icons/store_contBack.png" mode="widthFix"></image>
<view class="textContent">
<view class="company">
<image class="company-logo" :src="companyInfo.cover" mode="aspectFill"></image>
<view class="company-cont">
<view class="nowrap company-name">{{companyInfo.name}}</view>
<view class="company-tips">易货平台</view>
</view>
</view>
<view class="code">
<image class="code-img" :src="companyInfo.code" mode="aspectFit"></image>
<!-- <view class="code-text">简单扫一扫即可进入平台</view> -->
</view>
<!-- @click="shareCanvas" -->
<view class="codeBnt">
扫码推广
</view>
</view>
</view>
<canvas class="codeImg" canvas-id="qrcodeCard"></canvas>
</view>
</template>
<script>
import { companiesCode } from '@/apis/interfaces/store'
export default {
data() {
return {
companyInfo : ''
}
},
created() {
companiesCode().then(res=>{
this.companyInfo = res
})
},
methods: {
// 绘制图片
shareCanvas(e){
uni.showLoading({
title: '加载中',
})
// 下载头像
let avatarImg = new Promise(success=>{
uni.getImageInfo({
src : this.companyInfo.cover,
success : res => {
success(res.path)
}
})
})
// 下载二维码
let codeImg = new Promise(success => {
uni.getImageInfo({
src : this.companyInfo.code,
success : res => {
success(res.path)
}
})
})
Promise.all([avatarImg, codeImg]).then(res => {
// 绘制海报
const ctx = uni.createCanvasContext('qrcodeCard')
ctx.save()
// 绘制背景图片
ctx.drawImage('../../static/icons/store_downBack', 0, 0, 375, 603)
// 绘制头像
ctx.drawImage(res[0], 0, 0, 60, 60)
// 绘制二维码
ctx.drawImage(res[1], 140, 250, 110, 110)
// 文字
ctx.setFontSize(16)
ctx.fillText(this.companyInfo.name, 194, 180 , 270)
ctx.setFontSize(16)
ctx.fillText('邀请你加入易货平台', 194, 180 , 270)
ctx.save();
ctx.beginPath(); //开始绘制
ctx.arc(50 / 2 + 170, 50 / 2 + 110, 50 / 2, 0, Math.PI * 2, false);
ctx.clip();
// 保存图片
ctx.draw(true, () => {
uni.hideLoading()
uni.canvasToTempFilePath({
canvasId: 'qrcodeCard',
x: 0,
y: 0,
success: res => {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success : res=>{
if (res.errMsg == "saveImageToPhotosAlbum:ok"){
uni.showToast({
title: '分享海报已保存至相册',
icon : 'none'
})
}else{
uni.hideLoading()
}
},
fail : err=>{
if (err.errMsg == "saveImageToPhotosAlbum:fail auth deny"){
uni.showModal({
title : '提示',
content : '暂未授权小程序写入您的相册,无法存储二维码海报',
confirmColor: '#d82526',
confirmText : '去设置',
success : res=>{
if (res.confirm){
uni.openSetting()
}
}
})
}
}
})
}
})
})
}).catch(err=>{
uni.showToast({
title: '海报下载,请检查网络',
icon : 'none'
})
})
}
}
}
</script>
<style lang="scss" scoped>
.content {
background-color: #e93340;
height: 100vh;
width: 100vw;
}
.codeContent {
position: relative;
width: 100%;
height: 100vh;
.codeContent-back {
width: 100%;
height: 100%;
z-index: 1;
position: absolute;
}
.codeContent-cont {
left: 5%;
width: 90%;
top: 100px;
z-index: 2;
position: absolute;
}
.codeContent-tips {
position: absolute;
top: 0;
right: 20rpx;
width: 200rpx;
z-index: 2;
}
.textContent {
position: absolute;
padding: 20rpx 20rpx 0 40rpx;
box-sizing: border-box;
width: 70%;
z-index: 3;
left: 15%;
right: 15%;
top: 140px;
}
.company {
width: 100%;
.company-logo {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
}
.company-cont {
position: absolute;
width: 100%;
height: 230rpx;
left: 0;
top: 0;
padding: 20rpx 20rpx 30rpx 210rpx;
font-size: $title-size;
.company-name {
font-weight: 600;
margin: 10rpx 0;
}
.company-tips {
font-size: 26rpx;
color: #787878;
}
}
}
.code {
text-align: center;
width: 100%;
box-sizing: border-box;
margin-bottom: $margin;
.code-img {
width: 90%;
}
.code-text {
color: #787878;
margin-top: $margin - 10;
font-size: $title-size;
}
}
}
.codeBnt {
background-color: #e1293f;
text-align: center;
border-radius: 10rpx;
line-height: 90rpx;
font-weight: 600;
font-size: $title-size;
color: #FFFFFF;
box-shadow: 4rpx 0 10rpx rgba(155,0,19,.5);
position: relative;
}
/* canvas */
.codeImg {
position: absolute;
left: -1000%;
height: 603px;
width: 375px;
background: white;
}
</style>

249
pages/news/detail.vue Normal file
View File

@@ -0,0 +1,249 @@
<template>
<view class="News-detail" v-if="loaded">
<view class="item" v-for="(item,index) in items" :key="index" v-if="items.length>0"
@click="item.read_at === ''?read(index,item):noread(item)">
<view class="top">
<image src="/static/images/news_2_1.png" mode="widthFix"></image>
<!-- <image v-if="index===1" src="/static/img/news_1_1.png" mode="widthFix"></image>
<image v-if="index===2" src="/static/img/news_3_1.png" mode="widthFix"></image> -->
<view :style="item.read_at=== '' ?'flex:1;':'flex:1;color:#808080;'">{{item.title}}</view>
</view>
<view class="des">{{item.content}}</view>
<view class="time">{{item.created_at}}</view>
<view class="read_at" v-if="item.read_at === ''"></view>
</view>
<no-list v-if="items.length === 0" name='no-new1' txt="空空如也~" />
</view>
</template>
<script>
import {
notificationsList,
notificationsDetail,
notificationsReaded
} from '@/apis/interfaces/news.js'
export default {
data() {
return {
items: [],
page: 1,
has_more: true,
loaded: false
};
},
onLoad(e) {
this.type = e.type
this.notificationsList()
},
onReachBottom() {
this.notificationsList()
},
// 右侧全部已读
onNavigationBarButtonTap(e) {
// #ifdef APP-PLUS
var currentWebview = this.$mp.page.$getAppWebview()
var tn = currentWebview.getStyle().titleNView
var text = tn.buttons[0].text
if (text == '全部已读') {
notificationsReaded(this.type).then(res => {
this.items.find((item, index) => {
this.$set(item, 'read_at', 'zdx')
})
uni.showToast({
title: '全部已读',
icon: 'none'
})
uni.setStorageSync('refresh',true)
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'nonde'
})
})
}
// #endif
},
methods: {
// 点击每个消息,假装查看详情,触发已读效果$set
read(index, item) {
let notification_id = item.notification_id
notificationsDetail(notification_id).then(res => {
this.$set(this.items[index], 'read_at', '已读已读')
uni.setStorageSync('refresh',true)
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'nonde'
})
})
if (item.url) {
switch (item.url.openType) {
case 'web':
// #ifdef APP-PLUS
plus.runtime.openURL(item.url.url)
return
// #endif
window.location.href = item.url.url
break;
case 'navigateTo':
uni.navigateTo({
url: item.url.path
})
break;
case 'switchTab':
uni.switchTab({
url: item.url.path
})
break;
default:
uni.showToast({
title: '活动过期,请联系系统管理员',
icon: 'none'
})
break;
}
}
},
// 消息列表
notificationsList() {
if (this.has_more) {
notificationsList(this.type, {
page: this.page
}).then(res => {
this.items = this.items.concat(res.data)
if (res.page.has_more) {
this.page = this.page + 1
}
this.has_more = res.page.has_more
this.loaded = true
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'nonde'
})
})
} else {
uni.showToast({
title: '没有更多啦~',
icon: 'none'
})
}
},
noread(item) {
if(item.url){
switch (item.url.openType) {
case 'web':
// #ifdef APP-PLUS
plus.runtime.openURL(item.url.url)
return
// #endif
window.location.href = item.url.url
break;
case 'navigateTo':
uni.navigateTo({
url: item.url.path
})
break;
case 'switchTab':
uni.switchTab({
url: item.url.path
})
break;
default:
uni.showToast({
title: '活动过期,请联系系统管理员',
icon: 'none'
})
break;
}
}else{
uni.showToast({
title: '哎呦,已经读过了~',
icon: 'none'
})
}
}
}
}
</script>
<style lang="scss">
.News-detail {
min-height: 100vh;
width: 100%;
padding: 0 $padding*1.5 $padding*1.5 $padding*1.5;
box-sizing: border-box;
.item {
background-color: #fff;
padding: $padding*1.5;
box-shadow: 0 0 40rpx 2rpx rgba(0, 0, 0, 0.1);
border-radius: $radius-m;
margin-top: $padding*1.5;
position: relative;
.top {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
box-sizing: border-box;
color: #353535;
font-weight: bold;
border-bottom: solid 1rpx #f8f8f8;
padding-bottom: $padding*1.3;
image {
width: 42rpx;
margin-right: $padding;
}
span {
font-size: $title-size;
}
}
.des {
font-size: $title-size-m;
padding-top: $padding;
color: #808080;
}
.time {
color: #999;
font-size: $title-size*0.9;
padding-top: $padding*0.9;
}
}
}
// 无消息
.no-news {
font-size: $title-size-m;
color: #666;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
box-sizing: border-box;
image {
width: 70%;
margin: $padding*7 0 $margin*3 0;
opacity: 0.6;
}
}
.read_at {
background-color: red;
width: 14rpx;
height: 14rpx;
position: absolute;
top: 20rpx;
right: 20rpx;
border-radius: 50%;
}
</style>

179
pages/news/index.vue Normal file
View File

@@ -0,0 +1,179 @@
<template>
<view class="News">
<view class="list" v-for="(item,index) in items" :key="index" v-if="items.length>0">
<navigator class="item" open-type="navigate" hover-class="none" :url="'/pages/news/detail?type='+item.type">
<view class="left">
<image class="img" v-if='item.type ==="SystemNotification"' :src="item.icon?item.icon:'/static/imgs/news_1.png'" mode="aspectFill"></image>
<image class="img" v-if='item.type ==="OrderNotification"' :src="item.icon?item.icon:'/static/imgs/news_2.png'" mode="aspectFill"></image>
<image class="img" v-if='item.type ==="CouponNotification"' :src="item.icon?item.icon:'/static/imgs/news_3.png'" mode="aspectFill"></image>
<view class="content">
<view class="title">{{item.name}}</view>
<view class="des">{{item.title || '暂无任何未读消息'}}</view>
</view>
</view>
<view class="num" v-if="item.count>0">{{item.count}}</view>
</navigator>
</view>
<view class="no-news" v-else>
<image src="/static/img/no-news.png" mode="widthFix"></image>
暂时没有收到任何消息~
</view>
</view>
</template>
<script>
import {
notificationsType,
notificationsDelete
} from '@/apis/interfaces/news.js'
export default {
data() {
return {
items: [],
editShow: false
};
},
onShow() {
this.notificationsType()
},
// 右侧编辑按钮触发事件
onNavigationBarButtonTap(e) {
let that = this
let index = e.index
// 按钮文字的改变所需
// #ifdef APP-PLUS
let currentWebview = that.$mp.page.$getAppWebview()
let tn = currentWebview.getStyle().titleNView
let text = tn.buttons[0].text
if (text == '全部清空') {
uni.showModal({
title: '是否确认清空全部消息',
content: '确认清空',
success(res) {
if (res.confirm) {
notificationsDelete().then(res => {
that.notificationsType()
uni.showToast({
title: '全部清除啦~',
icon: 'none'
})
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
}
}
})
}
// #endif
},
methods: {
notificationsType() {
notificationsType().then(res => {
this.items = res
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'nonde'
})
})
}
}
}
</script>
<style lang="scss">
.News {
height: 100vh;
// #ifdef APP-PLUS
min-height: calc(100vh - 20rpx);
// #endif
width: 100%;
// background-color: pink;
// 无消息
.no-news {
font-size: $title-size-m;
color: #666;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
box-sizing: border-box;
image {
width: 70%;
margin-top: $padding*7;
}
}
// 消息列表
.list {
width: 94%;
margin-left: 3%;
.item {
margin-top: 20rpx;
width: 100%;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
box-sizing: border-box;
padding: $padding*1.5;
background-color: #fff;
border-radius: $radius*0.6;
box-sizing: 0 0 20rpx 40rpx rgba(0, 0, 0, 0.3);
.left {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
box-sizing: border-box;
flex: 1;
.content {
flex: 1;
padding: 0 $padding*0.5;
box-sizing: border-box;
}
.img {
width: 80rpx;
height: 80rpx;
margin-right: $padding*1.2;
border-radius: 50%;
}
.title {
font-size: $title-size-m*1.1;
margin-bottom: $padding*0.5;
font-weight: bold;
}
.des {
font-size: $title-size-m*0.9;
color: #999;
}
}
.num {
background-color: $mian-color;
color: #fff;
border-radius: 50%;
width: 40rpx;
height: 40rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: $title-size*.8;
padding: $padding*0.3;
text-align: center;
}
}
}
}
</style>

View File

@@ -33,20 +33,28 @@
<u-icon name="arrow-right" color="#f1f1f1" size="28" />
</button>
<!-- 个人认证 -->
<view @click="certification(is_certification)" class="list-item">
<view @click="certificationClick(certification)" class="list-item">
<view class="list-item-left">
<image src="/static/imgs/self-icon.png" mode="widthFix" />
<span>个人认证</span>
</view>
<u-icon name="arrow-right" color="#f1f1f1" size="28" />
<view class="input">
<input type="text" :value="certification.is_true?'已认证':''"
:placeholder="certification.is_true?'':'未认证'" disabled="true" maxlength="12" />
<u-icon name="arrow-right" color="#f1f1f1" size="28" />
</view>
</view>
<!-- 企业认证 -->
<view @click="company(is_company)" class="list-item">
<view @click="company(companyCode.code)" class="list-item">
<view class="list-item-left">
<image src="/static/imgs/company-icon.png" mode="widthFix" />
<span>企业认证</span>
</view>
<u-icon name="arrow-right" color="#f1f1f1" size="28" />
<view class="input">
<input type="text" :value="companyCode.code=== 1?'已认证':''"
:placeholder="companyCode.code !== 1?companyCode.message:''" disabled="true" maxlength="12" />
<u-icon name="arrow-right" color="#f1f1f1" size="28" />
</view>
</view>
<!-- 关于我们 -->
<view @click="$router.push({name:'aboutUs'})" class="list-item">
@@ -80,7 +88,8 @@
import {
wechatbind,
resetUserInfo,
getUserSettingInfo
getUserSettingInfo,
companyStatus
} from '@/apis/interfaces/setting'
import {
uploads
@@ -96,8 +105,8 @@
showPath: ''
},
is_bind: true, // 微信绑定
is_certification: true, // 个人认证
is_company: true, // 企业认证
certification: {}, // 个人认证
companyCode: {}, // 企业认证 -1.未认证0.审核中1.审核通过2.驳回
}
},
onShow() {
@@ -107,38 +116,59 @@
}
})
this.getUserInfo()
},
onPullDownRefresh() {
this.getUserInfo()
},
methods: {
// 是否个人认证
certification(is_certfication) {
console.log(is_certfication)
if (is_certfication) {
certificationClick(certfication) {
console.log(certfication)
if (certfication.is_true) {
// 跳转到个人认证信息完成展示页面
this.$router.push({
name: ''
// this.$refs.uToast.show({
// title: '认证通过!',
// type: 'primary',
// duration: 3000
// })
uni.showModal({
title: '认证信息',
content: '真实姓名:<' + certfication.message.name + '>,身份证号:' + certfication.message.idcard,
showCancel:false
})
} else {
// 跳转到个人认证信息页面
this.$router.push({
name: ''
uni.navigateTo({
url: '/pages/certification/personal'
})
}
},
// 是否展示企业信息
company(is_company) {
console.log(is_company)
if (is_company) {
// 跳转到企业认证完成信息展示页面
this.$router.push({
name: ''
})
} else {
// 是否展示企业信息 企业认证 -1.未认证0.审核中1.审核通过2.驳回
company(code) {
console.log(code, '是否企业认证')
if (code === -1) {
// 跳转到企业认证页面
this.$router.push({
name: ''
uni.navigateTo({
url: '/pages/company/approve'
})
} else if (code === 2) {
// 跳转到企业认证页面
uni.navigateTo({
url: '/pages/company/approve?form_type=put'
})
} else if (code === 0) {
this.$refs.uToast.show({
title: '审核中',
type: 'primary',
duration: 3000
})
} else if (code === 1) {
// 跳转到企业认证页面
this.$refs.uToast.show({
title: '认证通过!',
type: 'primary',
duration: 3000
})
}
},
@@ -148,8 +178,7 @@
this.avatar.showPath = res.avatar
this.nickname = res.nickname
this.is_bind = res.is_bind
this.is_certification = res.is_certification
this.is_company = res.is_company
this.certification = res.certification
uni.stopPullDownRefresh()
}).catch(err => {
this.$refs.uToast.show({
@@ -158,6 +187,17 @@
duration: 3000
})
})
// -1.未认证0.审核中1.审核通过2.驳回
companyStatus().then(res => {
console.log(res)
this.companyCode = res
}).catch(err => {
this.$refs.uToast.show({
title: err.message,
type: 'primary',
duration: 3000
})
})
},
// 点击绑定用户得授权信息,且绑定带修改
getUser() {
@@ -385,8 +425,9 @@
flex: 1;
input {
padding-right: 30rpx;
padding-right: 20rpx;
width: 100%;
font-size: 30rpx;
}
}

327
pages/shop/create.vue Normal file
View File

@@ -0,0 +1,327 @@
<template>
<view>
<view class="create-form">
<view class="header">
<view @click="updLogo">
<image class="logo" style="border: none;" v-if="cover.showpath" :src="cover.showpath" mode="aspectFill" />
<image class="logo" v-else src="@/static/icons/add-icon.png" mode="aspectFill" />
</view>
<view class="inputs">
<input type="text" v-model="name" placeholder="门店/部门名称" />
</view>
<view class="inputs">
<input type="number" v-model="mobile" placeholder="门店联系电话" />
</view>
</view>
<view class="info">
<view class="inputs">
<label class="inputs-label">开店时间</label>
<picker mode="time" @change="pickerTime" :value="startTime" data-key="startTime">
<view class="time-text">
{{startTime || '选择开店时间'}}
<uni-icons class="time-icon" type="arrowdown" size="18" color="#999"></uni-icons>
</view>
</picker>
</view>
<view class="inputs">
<label class="inputs-label">闭店时间</label>
<picker mode="time" @change="pickerTime" :value="endTime" data-key="endTime">
<view class="time-text">
{{endTime || '选择闭店时间'}}
<uni-icons class="time-icon" type="arrowdown" size="18" color="#999"></uni-icons>
</view>
</picker>
</view>
<view class="inputs addrss-input">
<label class="inputs-label">门店地址</label>
<textarea class="inputs-textarea" v-model="address" placeholder="输入门店地址" auto-height/>
<view class="addrss-icon" @click="onLocation">
<uni-icons type="location-filled" size="20" color="#c82626"></uni-icons>
</view>
</view>
</view>
<view class="info">
<view class="inputs">
<label class="inputs-label">门店简介</label>
<textarea class="inputs-textarea" v-model="description" placeholder="门店简介..." />
</view>
</view>
</view>
<view class="create-btns">
<button class="item-btn btn-submit" type="default" @click="createShop">{{type === 'add' ? '创建': '保存'}}</button>
<button class="item-btn btn-delete" type="default" @click="onDeleteShop" v-if="type === 'edit'">删除</button>
</view>
</view>
</template>
<script>
import { create, putShop, deleteShop, editInfo } from '@/apis/interfaces/shop'
import { uploads } from '@/apis/interfaces/uploading'
export default {
data() {
return {
type : 'add',
id : '',
cover : {
showpath: '',
path : '',
},
name : '',
mobile : '',
address : '',
startTime : '',
endTime : '',
description : '',
latitude : '',
longitude : ''
};
},
onLoad() {
if(this.$Route.query.id){
this.type = 'edit'
this.getInfo()
}
},
methods:{
// 获取编辑信息
getInfo(){
editInfo(this.$Route.query.id).then(res => {
this.id = res.store_id
this.cover = res.cover
this.name = res.name
this.mobile = res.mobile
this.address = res.address
this.startTime = res.start_time
this.endTime = res.end_time
this.description= res.description
this.latitude = res.latitude
this.longitude = res.longitude
})
},
// 获取地址
onLocation(){
uni.chooseLocation({
success: res => {
this.address = res.address
this.longitude = res.longitude
this.latitude = res.latitude
},
fail: err => {
uni.showToast({
title: err,
icon : 'none'
})
}
})
},
// 选择营业时间
pickerTime(e){
this[e.target.dataset.key] = e.detail.value
},
// 编辑创建
createShop(){
let data = {
cover : this.cover.path,
name : this.name,
mobile : this.mobile,
address : this.address,
latitude : this.latitude,
longitude : this.longitude,
description : this.description,
start_time : this.startTime,
end_time : this.endTime
}
if(this.type === 'edit'){
putShop(this.id, {...data}).then(res => {
uni.showModal({
title : '提示',
content : res,
showCancel : false,
success : modalRes => {
this.$Router.back()
}
})
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
return
}
create({...data}).then(res => {
uni.showModal({
title : '提示',
content : res,
showCancel : false,
success : modalRes => {
this.$Router.back()
}
})
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
},
// 删除门店
onDeleteShop(){
deleteShop(this.id).then(res => {
uni.showModal({
title : '提示',
content : res,
showCancel : false,
success : modalRes => {
this.$Router.back()
}
})
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
},
// 上传logo
updLogo(){
uni.chooseImage({
crop: { width: 188, height: 188 },
success: path => {
uploads([{
name: 'logo',
uri : path.tempFilePaths[0]
}]).then(res => {
this.cover = {
showpath: res.url[0],
path: res.path[0]
}
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
}
})
}
}
}
</script>
<style lang="scss" scoped>
// 门店信息
.create-form{
.header{
position: relative;
background: white;
padding-left: $padding + 150;
.logo{
width: 108rpx;
height: 108rpx;
border-radius: 50%;
position: absolute;
left: $padding;
top: 26rpx;
border: dashed 2rpx $border-color;
box-sizing: border-box;
}
.inputs{
position: relative;
padding-right: $padding;
input,
.time-text{
line-height: 80rpx;
height: 80rpx;
font-size: $title-size-lg;
}
&::after{
position: absolute;
left: 0;
bottom: 0;
right: 0;
content: " ";
height: 1rpx;
background: $border-color;
}
&:last-child::after{
display: none;
}
.time-text{
padding-right: 80rpx;
.time-icon{
position: absolute;
height: 80rpx;
line-height: 80rpx;
text-align: right;
width: 80rpx;
right: $padding;
top: 0;
}
}
}
}
.info{
@extend .header;
margin-top: $margin;
padding-left: 0;
background: white;
.inputs{
padding-left: $padding + 150;
.inputs-label{
position: absolute;
left: $padding;
top: 0;
font-size: $title-size-lg;
line-height: 80rpx;
height: 80rpx;
width: 150rpx;
}
.inputs-textarea{
width: 100%;
padding: 20rpx 0;
height: 160rpx;
font-size: $title-size-lg;
line-height: 40rpx;
}
&.addrss-input{
padding-right: $padding + 100;
.addrss-icon{
position: absolute;
height: 80rpx;
line-height: 80rpx;
text-align: right;
width: 80rpx;
right: $padding;
top: 0;
}
}
}
}
}
// 按钮组
.create-btns{
padding: $padding;
.item-btn{
border-radius: 0;
background: white;
font-size: $title-size;
line-height: 90rpx;
height: 90rpx;
&::after{
border: none;
}
}
.btn-submit{
background: $text-price;
color: white;
font-weight: bold;
margin-bottom: $margin;
}
.btn-delete{
border: solid 1rpx $border-color;
color: $text-gray;
}
}
</style>

120
pages/shop/lists.vue Normal file
View File

@@ -0,0 +1,120 @@
<template>
<view class="lists">
<block v-if="lists.length > 0">
<view class="lists-item" v-for="(item, index) in lists" :key="index" @click="$Router.push({name: 'shopCreate', params: { id: item.store_id }})">
<view class="header">
<image class="logo" :src="item.cover" mode="aspectFill"></image>
<view class="title">{{item.name}}</view>
<view class="time"><text>营业时间{{item.start_time}} {{item.end_time}}</text></view>
<view class="icons">
<uni-icons type="arrowright" color="#999" size="18"></uni-icons>
</view>
</view>
<view class="address">店铺地址{{item.address}}</view>
</view>
</block>
<block v-else>
<view class="list-null">
<image class="icon" src="@/static/icons/approve-icon.png" mode="widthFix"></image>
<view class="sub-title">暂未创建店铺/部门</view>
<view class="sub-btn" @click="$Router.push({name: 'shopCreate'})">创建</view>
</view>
</block>
</view>
</template>
<script>
import { shops } from '@/apis/interfaces/shop'
export default {
data() {
return {
lists: []
};
},
onShow(){
shops().then(res => {
console.log(res)
this.lists = res.data
})
}
}
</script>
<style lang="scss">
// 空提示
.list-null{
width: 100vw;
height: 100vh;
padding-bottom: 20vh;
box-sizing: border-box;
background: white;
text-align: center;
@extend .vertical;
.sub-title{
color: $text-gray;
font-size: $title-size-m;
}
.icon{
width: 288rpx;
}
.sub-btn{
width: 200rpx;
height: 70rpx;
line-height: 70rpx;
text-align: center;
background: $mian-color;
color: white;
display: inline-block;
margin-top: $margin*2;
}
}
// 列表
.lists-item{
background: white;
margin: $margin;
border-radius: $radius/2;
padding: $padding;
.header{
position: relative;
padding-left: 128rpx;
padding-right: 100rpx;
min-height: 108rpx;
padding-bottom: $padding - 10;
.logo{
position: absolute;
top: 0;
left: 0;
width: 108rpx;
height: 108rpx;
border-radius: 50%;
}
.title{
line-height: 60rpx;
font-size: $title-size;
font-weight: bold;
}
.time{
line-height: 40rpx;
font-size: $title-size-sm;
text{
background-color: $border-color-lg;
color: $text-gray;
padding: 0 $padding/2;
}
}
.icons{
position: absolute;
right: 0;
top: 0;
line-height: 108rpx;
}
}
.address{
border-top: solid 1rpx $border-color;
padding-top: $padding - 10;
font-size: $title-size-m;
color: $text-gray;
left: 50rpx;
}
}
</style>

View File

@@ -127,7 +127,7 @@
<view class="withdraw-name">
当前能量球价值<view class="withdraw-number">0.00</view>
</view>
<view class="withdraw-btn">
<view class="withdraw-btn" @click="$Router.push({name: 'Extract'})">
去提现
</view>
</view>
@@ -136,12 +136,12 @@
我的资产
</view>
<view class="assets-list" v-if="userData.account">
<view class="assets-label">
<view class="assets-label-name">能量球钱包<image @click="showHelp('wallet')" class="assets-label-icon" src="/static/user/userAssets_tips.png"></image></view>
<view class="assets-label" @click="$Router.push({name:'walletProperty'})">
<view class="assets-label-name">能量球钱包<image @click.stop="showHelp('wallet')" class="assets-label-icon" src="/static/user/userAssets_tips.png"></image></view>
<view class="assets-label-number">{{userData.account.coins || 0}}</view>
</view>
<view class="assets-label">
<view class="assets-label-name">能量碎片<image @click="showHelp('chip')" class="assets-label-icon" src="/static/user/userAssets_tips.png"></image></view>
<view class="assets-label" @click="$Router.push({name:'Fragment'})">
<view class="assets-label-name">能量碎片<image @click.stop="showHelp('chip')" class="assets-label-icon" src="/static/user/userAssets_tips.png"></image></view>
<view class="assets-label-number">{{userData.account.score || 0}}</view>
</view>
</view>
@@ -183,7 +183,7 @@
<image class="tool-label-img" src="/static/user/userTool-01.png" mode=""></image>
<view class="tool-label-name">优惠券管理</view>
</view>
<view class="tool-label" @click="$Router.push({name: ''})">
<view class="tool-label" @click="$Router.push({name: 'instrumentSpread'})">
<image class="tool-label-img" src="/static/user/userTool-02.png" mode=""></image>
<view class="tool-label-name">营销推广码</view>
</view>
@@ -191,14 +191,18 @@
<image class="tool-label-img" src="/static/user/userTool-03.png" mode=""></image>
<view class="tool-label-name">基础信息</view>
</view>
<view class="tool-label">
<view class="tool-label" @click="$Router.push({name: 'shopLists'})">
<image class="tool-label-img" src="/static/user/userTool-04.png" mode=""></image>
<view class="tool-label-name">部门门店</view>
</view>
<view class="tool-label" @click="$Router.push({name: ''})">
<view class="tool-label" @click="$Router.push({name: 'employeesList'})">
<image class="tool-label-img" src="/static/user/userTool-05.png" mode=""></image>
<view class="tool-label-name">员工管理</view>
</view>
<!-- <view class="tool-label" @click="$Router.push({name: 'verificationIndex'})">
<image class="tool-label-img" src="/static/user/userTool-05.png" mode=""></image>
<view class="tool-label-name">扫码核销</view>
</view> -->
</view>
</view>

View File

@@ -270,7 +270,7 @@
width: calc(100% - 60rpx);
height: 360rpx;
background-image: linear-gradient(to left, #076cff, #076cff);
box-shadow: 0 10rpx 20rpx 0rpx rgba($color: $main-color, $alpha: 0.4);
box-shadow: 0 10rpx 20rpx 0rpx rgba($color: $mian-color, $alpha: 0.4);
margin: 0 30rpx;
border-radius: 20rpx;
box-sizing: border-box;

65
pages/wallet/add.vue Normal file
View File

@@ -0,0 +1,65 @@
<template>
<view class="content webkit-box">
<!-- logo -->
<image class="logo" src="@/static/img/oc-logo.png" mode="widthFix"></image>
<!-- 副标题 -->
<view class="sub-title">激活您的OC Chain区块链钱包地址</br>地址可以理解为您的个人银行卡卡号与他人转账时是区块链上两个地址的交易行为</view>
<!-- 按钮 -->
<navigator class="wallet-btn" url="./mnemonic" open-type="redirect">激活钱包</navigator>
<!-- <navigator class="wallet-btn hollow" url="./guide">导入钱包</navigator> -->
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
page {
background-color: white;
}
</style>
<style lang="scss" scoped>
.content{
position: relative;
height: 100vh;
padding: 0 15vw;
text-align: center;
.logo{
width: 138rpx;
vertical-align: top;
margin-bottom: 30vh;
}
.sub-title{
font-size: $title-size-m;
color: $text-gray;
}
.wallet-btn{
width: 100%;
background-color: $mian-color;
height: 90rpx;
line-height: 90rpx;
margin-top: $margin * 2;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
&.hollow{
background-color: white;
color: $mian-color;
border:solid 2rpx $mian-color;
box-sizing: border-box;
}
}
}
</style>

View File

@@ -0,0 +1,50 @@
<template>
<view>
<view class="clauseCont">
<rich-text :nodes="clauseData"></rich-text>
</view>
</view>
</template>
<script>
import {
cmsWithdraw
} from '@/apis/interfaces/wallet.js'
export default {
data() {
return {
clauseData: [] //服务条款
};
},
onLoad() {
// 获取服务条款
this.clauseInfo()
},
methods: {
// 服务条款
clauseInfo() {
cmsWithdraw().then(res => {
this.clauseData = res.content.replace(/\<img/gi,
'<img style="max-width:100%; height:auto; vertical-align: top;"')
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
},
}
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color;
}
.clauseCont {
padding: $padding + 10 $padding * 2;
width: 100%;
box-sizing: border-box;
}
</style>

136
pages/wallet/code.vue Normal file
View File

@@ -0,0 +1,136 @@
<template>
<view class="webkit-box code">
<view class="webkit-box code-content">
<view class="sub-title">扫码转入OC COIN</view>
<view class="code-img">
<image :src="code" mode="widthFix" />
</view>
<view class="hr"></view>
<view class="sub-title">钱包地址</view>
<view class="hash">{{address || '-'}}</view>
<view class="buttons">
<button class="item red" type="default" @click="showShare()">分享</button>
<button class="item greed" type="default" @click="copyAddress">复制</button>
</view>
</view>
<view class="footer">OC CHNIA</view>
</view>
</template>
<script>
import { code } from '@/apis/interfaces/wallet'
export default {
data() {
return {
address: '',
code: ''
};
},
mounted() {
code().then(res=>{
this.code = res.image
this.address = res.address
}).catch(err=>{
uni.showToast({
icon: 'none',
title: err.message
})
})
},
methods:{
copyAddress(){
uni.setClipboardData({
data: this.address
})
},
showShare(){
uni.share({
provider: 'weixin',
title: '我正在使用ocChain钱包收款',
scene: 'WXSceneSession',
href: 'https://live.funnyzhibo.com/blockdownload',
imageUrl: 'https://live.funnyzhibo.com/oc-chain.png',
summary: '我的收款地址' + this.address
})
}
}
}
</script>
<style lang="scss" scoped>
.code{
height: 100vh;
background:linear-gradient(to bottom, $mian-color, $mian-color-deep);
padding-bottom: env(safe-area-inset-bottom);
padding-bottom: constant(safe-area-inset-bottom);
box-sizing: border-box;
// 收款码
.code-content{
text-align: center;
background: white;
margin: 0 8vw;
border-radius: $radius;
padding: $padding * 2;
height: 70vh;
box-shadow: 0 0 6rpx 6rpx rgba($color: #000000, $alpha: .02);
box-sizing: border-box;
.sub-title{
font-size: $title-size + 8;
}
.code-img{
width: 20vh;
height: 20vh;
margin: $margin * 3 0 $margin * 2;
display: inline-block;
background-image: url(../../static/background/wallet-code-background.png);
padding: $padding;
box-sizing: border-box;
background-position: center;
background-size: cover;
image{
width: 100%;
}
}
.hr{
height: 1rpx;
background: $border-color;
margin: $margin * 2 0;
}
.hash{
word-wrap: break-word;
font-size: $title-size;
padding: $padding 0;
}
.buttons{
display: flex;
padding-top: $padding * 2;
.item{
width: 40%;
height: 80rpx;
line-height: 80rpx;
border-radius: 40rpx;
font-size: $title-size;
color: white;
&::after{
border: none;
}
&.red{
background: $red-color;
}
&.greed{
background: $mian-color;
}
}
}
}
// 底部
.footer{
height: 10vh;
line-height: 10vh;
text-align: center;
font-size: $title-size + 10;
font-weight: bold;
color: #58876e;
}
}
</style>

138
pages/wallet/create.vue Normal file
View File

@@ -0,0 +1,138 @@
<template>
<view>
<!-- 设置钱包密码 -->
<view class="password">
<view class="prompt">请设置6位数字密码建议不要使用连续的数字</view>
<view class="group">
<view class="inputs">
<label>密码</label>
<input type="digit" v-model="password" maxlength="6" placeholder="请设置密码" />
</view>
<view class="inputs">
<label>确认密码</label>
<input type="digit" v-model="verify" maxlength="6" placeholder="请确认密码" />
</view>
</view>
</view>
<!-- 按钮 -->
<view class="buttons">
<button type="default" form-type="submit" @click="createWallet">确认</button>
</view>
</view>
</template>
<script>
import {
security
} from '@/apis/interfaces/wallet'
export default {
data() {
return {
password: '',
verify: ''
}
},
methods: {
// 激活钱包
createWallet() {
if (this.password === '' || this.verify === '') {
uni.showToast({
icon: 'none',
title: '请设置密码'
})
return
}
if (this.password !== this.verify) {
uni.showToast({
icon: 'none',
title: '两次输入密码不一致'
})
return
}
security({
code: this.password
}).then(res => {
uni.navigateBack()
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
}
}
}
</script>
<style lang="scss" scoped>
// 副标题
.sub-title {
color: $text-gray;
text-align: center;
margin: $margin * 2 $margin;
font-size: $title-size-m;
}
// 设置密码
.password {
padding: 0 $padding * 2;
.prompt {
margin-top: $margin * 2;
font-size: $title-size-m;
color: $mian-color;
}
.group {
margin-top: $margin;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
.inputs {
padding: $padding $padding + 10;
border-bottom: solid 1rpx $border-color;
&:last-child {
border-bottom: none;
}
label {
color: $text-gray;
font-size: $title-size-m;
}
input {
height: 70rpx;
line-height: 70rpx;
font-size: $title-size;
}
}
}
}
// 按钮
.buttons {
padding: $padding * 2;
.text {
text-align: center;
line-height: 90rpx;
height: 90rpx;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $mian-color;
font-weight: bold;
}
button {
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
}
}
</style>

393
pages/wallet/extract.vue Normal file
View File

@@ -0,0 +1,393 @@
<template>
<view class="WithdrawingCoin ">
<view class="withdrawing-content">
<view class="item-name">能量球提现至银行卡</view>
<view class="item">
<view style="flex: 1;">
<input class="input_num" v-model="withdraw_input" @input='inputNum' type="number"
placeholder-style="color:#999;font-weight:normal; font-size:30rpx;" placeholder="请输入能量球数量" />
<view v-if="total"> {{total}}</view>
</view>
<view class="all" @click="all">全部提现</view>
</view>
<view class="item">
<input class="input_num" v-model="card" type="number"
placeholder-style="color:#999;font-weight:normal; font-size:30rpx;" placeholder="请输入您要收款得银行卡卡号" />
</view>
<view class="item">
<input class="input_num" v-model="name" maxlength="10"
placeholder-style="color:#999;font-weight:normal; font-size:30rpx;" placeholder="请输入收款人姓名" />
</view>
<number-jpan :length="6" @closeChange="closeChange($event)" ref="numberPad"></number-jpan>
<view class="item-total">
<view class="total"><span>能量球总数 : {{balance}}</span><span class="money">总估值(CNY){{(balance*price).toFixed(2)}}</span></view>
</view>
</view>
<view class="btn" @click="open">提现至银行卡</view>
<view class="ew_lists" v-if="withdrawLists.length>0">
<view class="" v-for="(item,index) in withdrawLists " :key="index">
<view class="receiptCode">
回执单号{{item.receipt_code}}
</view>
<view class="item">
<view class="left">
<span>能量球:{{item.total}}</span>
<span>金额{{item.arrival}}</span>
</view>
<view class="right">
<span> {{item.created_at}} 提现</span>
<span> {{item.paid_at?item.paid_at+'到账':'努力打款中'}}</span>
</view>
</view>
</view>
<view class="hasmore">
{{has_more?'努力加载中~':'我是有底线的~'}}
</view>
</view>
<no-list v-else name='no-records' txt="暂无任何提现记录哦~" />
</view>
</template>
<script>
import {
withdraw,
withdrawLogs,
withdrawDo
} from '@/apis/interfaces/wallet.js';
import numberJpan from "@/components/numberJpan/numberJpan.vue";
export default {
data() {
return {
balance: 0, // 钱包能量球数量
price: 0, // 当前能量球价格
card: '', // 银行卡号
name: '', // 姓名
password: '', //
withdraw_input: '', // 提现能量球数量
total: '', // 提现能量球转化成的钱数
page: 1,
has_more: true,
withdrawLists: [],
};
},
components: {
'number-jpan': numberJpan
},
onLoad() {
this.reset()
},
onReachBottom() {
if (this.withdrawLists.length > 0) {
if (this.has_more) {
this.withdrawLogs()
} else {
uni.showToast({
title: '没有更多~',
icon: 'none'
})
}
}
},
methods: {
// 提现基本信息
withdraw() {
withdraw().then(res => {
this.balance = Number(res.balance)
this.price = Number(res.price)
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
},
// 提现记录
withdrawLogs() {
withdrawLogs({
page: this.page
}).then(res => {
this.withdrawLists = this.withdrawLists.concat(res.data)
if (res.page.has_more) {
this.page = this.page + 1
this.has_more = true
} else {
this.has_more = false
}
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
},
// 输入提现能量球数量
inputNum(e) {
let number = Number(e.detail.value)
if (number <= this.balance) {
this.total = Number(e.detail.value) * this.price
} else {
uni.showToast({
title: '最大值能超过' + this.balance+'',
icon: 'none',
duration: 2000
});
this.withdraw_input = ''
this.total = 0
}
},
// 点击全部
all() {
if (this.balance > 0) {
this.withdraw_input = this.balance
this.total = this.balance * this.price
} else {
uni.showToast({
title: '啥也没有,我也做不到~',
icon: 'none',
duration: 2000
})
}
},
// 打开密码 出发提现功能
open() {
if (this.total > 0) {
let params = {
name: this.name,
card: this.card,
total: this.withdraw_input
}
if (params.name === '' || params.card === '' || params.total === 0) {
uni.showToast({
title: '重新确认提现信息',
icon: 'none',
duration: 2000
})
} else {
this.$refs.numberPad.open()
}
} else {
uni.showToast({
title: '啥也没有,我也做不到~',
icon: 'none',
duration: 2000
})
}
},
// 输入密码成功后,,,
closeChange(e) {
uni.showLoading({
title: '提现中~'
})
let params = {
name: this.name,
card: this.card,
total: this.withdraw_input,
code: e
}
withdrawDo(params).then(res => {
uni.showToast({
title: '申请提现成功,耐心等待打款',
icon: 'none',
duration: 2000
})
this.reset()
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none',
duration: 2000
})
})
},
reset() {
this.name = ''
this.card = ''
this.page = 1
this.has_more = true
this.withdraw_input = ''
this.total = 0
this.withdrawLists = []
this.withdrawLogs();
this.withdraw();
}
}
}
</script>
<style lang="scss">
page{
width: 100%;
min-height: 100vh;
background-color: #fff;
}
.hasmore {
color: #808080;
font-size: $title-size-m;
text-align: center;
padding: $padding*2;
}
.nomore {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-size: $title-size-m;
color: #808080;
margin-top: $margin*4;
image {
width: 320rpx;
margin-bottom: $margin*2;
}
}
.receiptCode {
color: #808080;
text-align: left;
// margin: $margin 0;
font-size: $title-size-m;
}
.WithdrawingCoin {
background-color: #fff;
width: 100%;
min-height: 100vh;
padding-bottom: 100rpx;
}
.all {
color: $text-price;
width: 160rpx;
text-align: center;
}
.withdrawing-content {
min-height: 300rpx;
background-color: #fff;
box-shadow: 0 0 30rpx 1rpx rgba($color: #000000, $alpha: 0.2);
margin: $margin*1.4;
border-radius: 20rpx;
padding: $padding*1.4 ;
font-size: $title-size-m;
.item-name {
text-align: center;
padding: $padding * .6;
color: #303030;
font-weight: bold;
margin-bottom: $margin;
font-size: $title-size *1.2;
}
.item {
border-bottom: solid 1rpx #f8f8f8;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
padding: $padding 0;
span:nth-child(1) {
color: #666;
margin-right: 20rpx;
}
.input_num {
font-size: $title-size*1.5;
color: #3a3a3a;
font-weight: bolder;
flex: 1;
}
}
.item-total {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: $padding*1 0 0 0;
color: #3a3a3a;
.total {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
box-sizing: border-box;
.money {
padding-top: $padding *0.5;
}
}
.lists {
color: $text-price;
}
}
}
.btn {
background-image: linear-gradient(to right, #7c52fc, #976dff);
color: #fff;
border-radius: 10rpx;
text-align: center;
padding: $padding * .9 ;
margin: $margin * 2;
font-size: $title-size;
font-weight: bold;
}
.ew_lists {
padding: $padding *2;
border-top: solid 4rpx #f8f8f8;
.item {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
border-bottom: solid 1rpx #f8f8f8;
background-color: #fff;
padding: 0 0 $padding*0.8 0;
.left,
.right {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
box-sizing: border-box;
}
.left {
font-size: $title-size-m;
font-weight: bold;
color: #808080;
span:nth-child(2) {
color: $text-price;
font-size: $title-size-m;
font-weight: normal;
padding-top: $padding *0.5;
}
}
.right {
font-size: $title-size-m;
align-items: flex-end;
color: #666;
span:nth-child(1) {
padding-bottom: $padding*0.5;
}
}
}
}
</style>

338
pages/wallet/fragment.vue Normal file
View File

@@ -0,0 +1,338 @@
<template>
<view class="Record">
<view class="record-top">
<image src="/static/imgs/account-bg.png" mode="widthFix" class="record-bg" />
<view class="record-top-nav">
<view :class="['record-top-item',type==='year'?'selectTopItem':'']"
@click="selectType('year')">年账单</view>
<view :class="['record-top-item',type==='month'?'selectTopItem':'']"
@click="selectType('month')">月账单</view>
<view :class="['record-top-item',type==='day'?'selectTopItem':'']"
@click="selectType('day')">日账单</view>
</view>
<view class="record-mouth-year">
<view class="record-type-right">
<view class="record-title">碎片个数</view>
<view class="record-money">{{account || '0.00'}} <span></span> </view>
</view>
<view class="record-type-left">
<u-picker mode="time" v-model="show" :params="params"
@confirm ='confirm' title ='筛选日期' start-year='2021' :end-year='currentYear'/>
<view @click="show = true">
{{date?date:'选择日期'}}
<uni-icons type="arrowdown" color="#fff" size="12" />
</view>
</view>
</view>
<!-- <view class="record-title">碎片个数</view>
<view class="record-money"><span></span>{{account || '0.00'}}</view> -->
</view>
<!-- 列表 -->
<view class="record-list" v-if="lists.length>0">
<view class="record-list-item" v-for="(item,index) in lists" :key='index'>
<image src="/static/imgs/record-icon.png" mode="widthFix" class="record-icon" />
<view class="">
<view class="record-list-item-top">
<view class="title ellipsis-2">完成任务获得碎片</view>
<view class="money" >{{cointype==='in'?'+':'-'}}5</view>
</view>
<view class="record-list-item-date">2021-12-22 12:12:12</view>
</view>
</view>
</view>
<!-- 无列表 -->
<no-list v-if="lists.length === 0" name='no-record' txt="没有任何碎片记录 ~ " />
<!-- <u-toast ref="uToast" /> -->
<u-toast ref="uToast" />
</view>
</template>
<script>
import {chaineb} from '@/apis/interfaces/mine';
export default {
data() {
return {
lists:[1,1.1,1,1],
has_next_page:true,
page:1,
type:'year', // 统计类型day日month月year年
cointype:'in',// in 收入 out 支出
date:new Date().toISOString().slice(0,4), // 日Y-m-d月Y-m年Y
params: {
year: true,
month: false,
day: false
},
show: false, // 显示
currentDay:new Date().toISOString().slice(0,10),
currentMonth:new Date().toISOString().slice(0,7),
currentYear:new Date().toISOString().slice(0,4),
account:''
}
},
onLoad(){
this.getList()
},
onReachBottom(){
if (this.has_next_page) {
this.page = this.page + 1
this.getList()
} else {
this.$refs.uToast.show({
title: '吼吼吼~我是有底的~',
type: 'primary',
duration: 3000
})
}
},
methods: {
// 获取列表
getList(){
let data = {
page:this.page,
type:this.type,
date:this.date,
cointype:this.cointype
}
chaineb(data).then(res => {
this.account = res.account
this.lists = this.lists.concat(res.lists)
this.has_next_page = res.has_next_page
}).catch(err => {
this.$refs.uToast.show({
title: err.message,
type: 'primary',
duration: 3000
})
})
},
selectCoinType(type){
if(this.cointype !== type){
this.cointype = type
this.reset()
}
},
// 重置
reset(){
this.page = 1
this.lists = []
this.has_next_page = true
this.getList()
},
// 选择 年 月 日 切换要重置数据
selectType(type){
if(this.type !== type){
switch(type){
case 'year':
this.type = type
this.params= {
year: true,
month: false,
day: false
}
this.date = this.currentYear
this.reset()
break;
case 'month':
this.type = type
this.params= {
year: true,
month: true,
day: false
}
this.date = this.currentMonth
this.reset()
break;
case 'day':
this.type = type
this.params= {
year: true,
month: false,
day: false
}
this.date = this.currentDay
this.reset()
break;
}
}
},
// 点击确认按钮
confirm(e){
let type = this.type
switch(type){
case 'year':
this.date = e.year
this.reset()
break;
case 'month':
this.date = e.year + '-' + e.month
this.reset()
break;
case 'day':
this.date = e.year + '-' + e.month + '-' + e.day
this.reset()
break;
}
}
}
}
</script>
<style lang="scss" scoped>
.Record {
width: 100%;
height: 100vh;
padding-top: 30rpx;
background-color: #fff;
}
.record-top {
width: calc(100% - 60rpx);
height: 360rpx;
background-image: linear-gradient(to right, #7c52fc, #976dff);
box-shadow: 0 10rpx 20rpx 0rpx rgba($color: #976dff, $alpha: 0.4);
margin: 0 30rpx;
border-radius: 20rpx;
box-sizing: border-box;
position: relative;
padding: 10rpx 50rpx 20rpx 50rpx;
z-index: 1;
.record-bg {
position: absolute;
width: 100%;
bottom: 0;
right: 0;
z-index: 1;
opacity: .5;
}
.record-top-nav {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
.record-top-item {
margin: 40rpx 20rpx;
font-size: 30rpx;
font-weight: 500;
color: #fff;
}
.selectTopItem{
border-bottom: solid 4rpx #fff;
}
}
.record-mouth-year {
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: space-between;
box-sizing: border-box;
position: relative;
z-index: 2;
color: #fff;
font-size: 30rpx;
margin-top: 20rpx;
.record-type-left {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
uni-icons {
margin-left: 4rpx;
}
}
.record-type-right {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
box-sizing: border-box;
font-size: 24rpx;
flex: 1;
.pay_type_item {
margin: 0 10rpx;
padding: 2rpx 20rpx;
border-radius: 30rpx;
border: solid 1rpx rgba($color: #000000, $alpha: 0);
}
.pay_type_item_select{
border: solid 1rpx #f7f7f7;
}
}
}
.record-title {
font-size: 28rpx;
color: #fff;
padding:0 0 20rpx 0;
}
.record-money {
color: #fff;
font-size: 60rpx;
font-weight: bold;
span {
font-size: 24rpx;
font-weight: 400;
padding-left: 20rpx;
margin-right: 4rpx;
}
}
}
.record-list {
padding: 20rpx 30rpx;
.record-list-item {
padding: 20rpx 0;
border-bottom: solid 1rpx #f7f7f7;
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: flex-start;
box-sizing: border-box;
.record-icon{
width: 60rpx;
margin-right: 20rpx;
}
.record-list-item-top {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
width: 600rpx;
.title {
font-size: 28rpx;
width: 600rpx;
color: #444;
}
.money {
color: #ee4c47;
font-size: 32rpx;
font-weight: bold;
}
}
.record-list-item-date {
font-size: 26rpx;
color: #a6a6a6;
margin-top: 10rpx;
}
}
}
</style>

125
pages/wallet/guide.vue Normal file
View File

@@ -0,0 +1,125 @@
<template>
<view>
<form>
<!-- 副标题 -->
<view class="sub-title">输入您的钱包助记词导入</view>
<!-- 助记词 -->
<view class="word">
<textarea placeholder="输入助记词"></textarea>
</view>
<!-- 设置钱包密码 -->
<view class="password">
<view class="group">
<view class="inputs">
<label>钱包名称</label>
<input type="text" placeholder="输入钱包名称" />
</view>
</view>
<view class="title">不少于8个字符建议包含大小写符号特殊字符</view>
<view class="group">
<view class="inputs">
<label>密码</label>
<input type="password" placeholder="请设置密码" />
</view>
<view class="inputs">
<label>确认密码</label>
<input type="password" placeholder="请确认密码" />
</view>
</view>
</view>
<!-- 按钮 -->
<view class="buttons">
<view class="text">什么是助记词</view>
<button type="default" form-type="submit">开始导入</button>
</view>
</form>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
// 副标题
.sub-title{
line-height: 90rpx;
color: $text-gray;
text-align: center;
margin: $margin;
font-size: $title-size-m;
}
// 助记词
.word{
background-color: white;
margin: $margin * 2;
padding: $padding + 10;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
& textarea{
height: 200rpx;
}
}
// 设置密码
.password{
padding: 0 $padding * 2;
.title{
margin-top: $margin * 2;
font-size: $title-size-m;
color: $mian-color;
}
.group{
margin-top: $margin;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
.inputs{
padding: $padding $padding + 10;
border-bottom: solid 1rpx $border-color;
&:last-child{
border-bottom: none;
}
label{
color: $text-gray;
font-size: $title-size-m;
}
input{
height: 70rpx;
line-height: 70rpx;
font-size: $title-size;
}
}
}
}
// 按钮
.buttons{
padding: $padding * 2;
.text{
text-align: center;
line-height: 90rpx;
height: 90rpx;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $mian-color;
font-weight: bold;
}
button{
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
}
}
</style>

144
pages/wallet/index.vue Normal file
View File

@@ -0,0 +1,144 @@
<template>
<view class="animate__animated animate__fadeInRight">
<!-- 数字资产 -->
<view class="property">
<view class="title">总资产()</view>
<view class="number">0.00</view>
</view>
<!-- 资产列表 -->
<view class="lists">
<view class="lists-header">
资产列表
<uni-icons type="plus" size="24" color="#aa55ff"></uni-icons>
</view>
<view class="item" v-for="(item, index) in 2" :key="index" @click="propertyInfo(item)">
<view class="cost">
<image class="logo" src="" mode="" />
<view class="title ellipsis">OC COIN</view>
<view class="text ellipsis">0.21</view>
</view>
<view class="balance">
<view class="title ellipsis">120,330.00</view>
<view class="text ellipsis">25269.3000</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
};
},
methods:{
propertyInfo(e){
console.log(e)
uni.navigateTo({
url: './property'
})
}
}
}
</script>
<style scoped>
</style>
<style lang="scss" scoped>
// 数字资产
.property{
overflow: hidden;
position: relative;
margin-top: $margin;
margin-left: $margin + ($margin / 2);
background-color: $mian-color;
border-radius: $radius 0 0 $radius;
padding: ($padding * 3) ($padding * 3) ($padding * 3) ($padding * 2);
color: white;
font-weight: bold;
&::before,&::after{
background-color: rgba($color: $red-color, $alpha: .03);
border-radius: 50%;
content: " ";
position: absolute;
}
&::before{
top: -300rpx;
left: 40%;
height: 400rpx;
width: 400rpx;
}
&::after{
bottom: -200rpx;
left: -100rpx;
height: 300rpx;
width: 300rpx;
}
.title{
font-size: $title-size;
}
.number{
font-size: $title-size + 18;
}
}
// 资产列表
.lists{
padding: $margin + ($margin / 2);
.lists-header{
display: flex;
font-size: $title-size + 2;
color: $text-color;
font-weight: bold;
padding: $padding 0 ($padding/2) 0;
justify-content: space-between;
justify-items: center;
align-items: center;
}
.item{
background-color: white;
border-radius: $radius;
box-shadow: 0 0 4rpx 4rpx rgba($color: #000000, $alpha: .02);
margin-top: $margin;
padding: $padding * 2;
display: flex;
&:first-child{
margin-top: 0;
}
.cost{
position: relative;
margin-right: $margin;
padding-left: 108rpx;
width: 50%;
box-sizing: border-box;
.logo{
position: absolute;
left: 0;
top: 0;
width: 88rpx;
height: 88rpx;
border-radius: 50%;
background-color: $border-color;
margin-right: $margin;
}
}
.balance{
padding-left: $padding;
width: 50%;
text-align: right;
box-sizing: border-box;
}
.title{
font-weight: bold;
font-size: $title-size;
}
.text{
font-size: $title-size-m;
color: $text-gray;
}
}
}
</style>

108
pages/wallet/mnemonic.vue Normal file
View File

@@ -0,0 +1,108 @@
<template>
<view>
<!-- 提示信息 -->
<view class="prompt">
请按照顺序记录并确保正确备份助记词
</view>
<!-- 助记词 -->
<ul class="mnemonic">
<li v-for="(item, index) in mnemonic" :key="index">{{item}}</li>
</ul>
<!-- 按钮 -->
<view class="buttons">
<view class="text">助记词是用户账户的唯一标识不能分享给他人掌握该助记词即可控制该账户与钱包</view>
<button type="default" @click="goto('/pages/wallet/validation')">验证助记词</button>
</view>
<!-- <view class="skip">暂时不验证<navigator url="/pages/index/index" open-type="switchTab">点此跳过</navigator></view> -->
</view>
</template>
<script>
import { seed } from "../../apis/interfaces/wallet"
export default {
data() {
return {
mnemonic: [], // 助记词
sign : '' // 校验签名
}
},
onLoad() {
seed().then(res => {
this.mnemonic = res.seed.split(' ')
this.sign = res.sign
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
},
methods: {
goto(url){
uni.redirectTo({
url: url + '?seed=' + this.mnemonic + '&sign=' + this.sign
})
}
}
}
</script>
<style lang="scss" scoped>
// 提示信息
.prompt{
color: $text-gray;
text-align: center;
line-height: 90rpx;
font-size: $title-size-m;
}
// 跳过
.skip{
padding: $padding * 2;
text-align: center;
color: $text-gray;
navigator{
color: $mian-color;
margin-left: $margin/2;
display: inline-block;
}
}
// 助记词
.mnemonic{
margin: $margin $margin * 2;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
padding: $padding;
list-style: none;
display: flex;
flex-wrap: wrap;
li{
text-align: center;
height: 58rpx;
line-height: 58rpx;
width: 58rpx;
margin: $margin / 2;
color: $text-color;
background: rgba($color: $border-color, $alpha: .4);
}
}
// 按钮
.buttons{
padding: $padding $padding * 2;
.text{
text-align: center;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $red-color;
}
button{
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
}
}
</style>

108
pages/wallet/privatekey.vue Normal file
View File

@@ -0,0 +1,108 @@
<template>
<view>
<!-- 私钥 -->
<view class="keys">
<view class="title">您已接收OC Chain托管</view>
<view class="key">{{key || '-'}}</view>
<view class="copykey" @click="copykey">复制我的私钥</view>
</view>
<!-- 疑问 -->
<view class="doubt" v-if="rules.length > 0">
<view class="doubt-item" v-for="(item, index) in rules" :key="index">
<view class="title">{{item.title || '-'}}</view>
<view class="content">{{item.description || '-'}}</view>
</view>
</view>
<!-- 免责说明 -->
<view class="liability">
<navigator url="/pages/wallet/cmsWithDraw">免责条款</navigator>
</view>
</view>
</template>
<script>
import { privatekey, keyrules } from '@/apis/interfaces/wallet'
export default {
data() {
return {
key: "",
rules: []
};
},
mounted() {
Promise.all([privatekey(this.$Route.query.password), keyrules()]).then(res => {
let privatekey = res[0],
keyrules = res[1]
this.key = privatekey.private_key
this.rules = keyrules
})
},
methods:{
copykey(){
uni.setClipboardData({
data: this.key
})
}
}
}
</script>
<style lang="scss">
.keys{
margin: $margin * 2;
background: white;
padding: $padding * 2;
box-shadow: 0 0 4rpx 4rpx rgba($color: #000000, $alpha: .02);
border-radius: $radius;
.title{
text-align: center;
font-weight: bold;
font-size: $title-size + 4;
color: $text-color;
}
.key{
padding: $padding * 2 0;
text-align: center;
color: $mian-color;
word-wrap: break-word;
}
.copykey{
background-color: $mian-color;
color: white;
height: 95rpx;
line-height: 95rpx;
text-align: center;
font-size: $title-size;
border-radius: $radius-m;
font-weight: bold;
}
}
.doubt{
margin: $margin $margin * 2;
.doubt-item{
padding: $padding 0;
.title{
font-weight: bold;
color: $text-color;
line-height: 50rpx;
font-size: $title-size + 2;
}
.content{
color: $text-gray-lg;
font-size: $title-size-m;
line-height: 40rpx;
}
}
}
.liability{
text-align: center;
color: $text-gray;
@extend .ios-bottom;
navigator{
font-size: $title-size-sm;
display: inline-block;
line-height: 90rpx;
padding: 0 ($padding * 2);
}
}
</style>

357
pages/wallet/property.vue Normal file
View File

@@ -0,0 +1,357 @@
<template>
<view class="propertyIndex">
<view class="propery">
<image src="/static/imgs/account-bg.png" mode="aspectFill" class="record-bg" />
<view class="propery-content">
<view class="currency">能量球 ( {{ price || '0' }} CNY)</view>
<view class="balance">{{ balance.balance || '0' }}</view>
<view class="frozen">{{ balance.frozen || '0' }} 冻结中</view>
<view class="balance-flex">
<view class="balance-flex-item" @click="showAddress">区块链地址</view>
<!-- <view class="balance-flex-item" @click="showPrivatekey('privatekey')">我的私钥</view> -->
<view class="balance-flex-item" @click="$Router.push({name: 'Extract'})">能量球提现</view>
</view>
</view>
</view>
<!-- 账户记录 -->
<view class="record">
<view class="record-tabs">
<view class="tabs-item" :class="logsType === 0 ? 'show': ''" @click="onLogsType(0)">全部</view>
<view class="tabs-item" :class="logsType === 2 ? 'show': ''" @click="onLogsType(2)">收入</view>
<view class="tabs-item" :class="logsType === 1 ? 'show': ''" @click="onLogsType(1)">支出</view>
</view>
<record :list="logs" :logsType="logsType" />
<!-- ios安全距离 -->
<view class="ios-bottom"></view>
</view>
<!-- 支付密码 -->
<uni-popup ref="showPassword">
<view class="validationPassword">
<view class="from">
<view class="title">验证密码</view>
<input class="input" v-model="password" password placeholder="请验证安全密码"/>
</view>
<view class="buttons">
<view class="button cancel" @click="payPassword('cancel', passwordPages)">取消</view>
<view class="button confirm" @click="payPassword('confirm', passwordPages)">验证</view>
</view>
</view>
</uni-popup>
<!-- 原密码弹窗 -->
<!-- <number-jpan :length="6" @closeChange="closeChange($event)" ref="numberPad"></number-jpan> -->
</view>
</template>
<script>
import record from '@/components/property/record'
import {
sum,
price,
logs,
code,
securityCheck // 输入旧密码是否正确
} from '@/apis/interfaces/wallet'
import numberJpan from "@/components/numberJpan/numberJpan.vue";
export default {
components: {
record
},
data() {
return {
balance: {},
price: '0.00',
logs: [],
logsType: 0,
password: '',
passwordPages: ''
};
},
onShow() {
Promise.all([
sum(),
price(),
logs()
]).then(res => {
this.balance = res[0]
this.price = res[1]
this.logs = res[2]
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
},
methods: {
// 弹出私钥
showPrivatekey(pages){
this.passwordPages = pages
this.$refs.showPassword.open('center')
},
// 验证私钥
payPassword(type){
if(type === 'confirm'){
if(this.password === '') {
uni.showToast({
title: '请输入安全密码',
icon : 'none'
})
return
}
securityCheck(this.password).then(res => {
this.$refs.showPassword.close()
switch (this.passwordPages){
case 'privatekey':
this.$Router.push({name:'Privatekey', params: {password: this.password}})
break;
case 'resetPassword':
this.$Router.push({name:'ResetPassword', params: {password: this.password}})
break;
}
this.password = ''
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none',
})
})
return
}
this.$refs.showPassword.close()
},
// 交易记录
onLogsType(index) {
if (this.logsType === index) return
this.logsType = index
this.logs = []
logs({
flag: this.logsType
}).then(res => {
this.logs = res
})
},
// 区块地址
showAddress() {
uni.showModal({
title: '我的区块链地址',
content: '\n地址可以理解为银行卡卡号与他人转账时是区块链上的两个地址间的交易行为\n\n' + this.balance.address,
cancelText: '复制',
cancelColor: '#b11eff',
success: (res) => {
if (res.cancel) {
uni.setClipboardData({
data: this.balance.address
})
}
}
})
}
},
onNavigationBarButtonTap(e) {
if (e.index === 0) {
uni.showActionSheet({
// itemList: ['转账', '收款', '提币', '修改密码'],
itemList: ['提现', '修改密码'],
success: (res) => {
switch (res.tapIndex) {
case 0:
console.log('提现了,')
this.$Router.push({
name: 'Extract'
})
break;
case 1:
this.showPrivatekey('resetPassword')
break;
}
uni.hideLoading()
}
})
}
}
}
</script>
<style lang="scss" scoped>
.propertyIndex{
width: 100%;
min-height: 100vh;
background-color: #FFFFFF;
}
// 验证密码弹出层
.validationPassword{
background-color: white;
border-radius: $radius-m;
width: 70vw;
.from{
padding: $padding*2;
.title{
text-align: center;
font-size: $title-size;
padding-bottom: $padding*2;
font-weight: bold;
color: $text-price;
}
.input{
text-align: center;
height: 90rpx;
font-size: $title-size;
border-radius: $radius-m;
background: $border-color-lg;
padding: 0 ($padding*2);
}
}
.buttons{
display: flex;
border-top: solid 1rpx $border-color;
.button{
width: 50%;
font-size: $title-size;
line-height: 90rpx;
height: 90rpx;
text-align: center;
box-sizing: border-box;
&.cancel{
border-right: solid 1rpx $border-color;
color: $text-gray;
}
&.confirm{
color: $text-price;
}
}
}
// .button{
// background-color: $text-price;
// color: white;
// border-radius: $radius-m;
// border: none;
// margin-top: $margin*2;
// font-size: $title-size;
// height: 90rpx;
// line-height: 90rpx;
// }
// .close{
// @extend .button;
// text-align: center;
// color: $text-gray;
// margin-top: $margin;
// background-color: transparent;
// }
}
// 账户
.propery {
position: relative;
padding-top: var(--status-bar-height);
background-image: linear-gradient(to right, #7c52fc, #976dff);
position: relative;
overflow: hidden;
.record-bg {
position: absolute;
width: 120%;
height: 300rpx;
bottom: -10rpx;
right: -20rpx;
z-index: 1;
opacity: .5;
transform:rotate(-7deg);
}
// &::before {
// position: absolute;
// left: 0;
// top: 0;
// width: 100%;
// height: 100%;
// content: " ";
// background-image: url(@/static/imgs/account-bg.png);
// background-size: 100%;
// background-repeat: no-repeat;
// opacity: .5;
// transform:rotate(0deg);
// }
.propery-content {
position: relative;
z-index: 1;
padding: $padding *3 $padding *1.4;
text-align: center;
.currency {
font-size: $title-size-m;
color: rgba($color: white, $alpha: .8);
}
.balance {
font-size: $title-size * 2.5;
padding: $padding 0;
color: white;
}
.frozen {
background: rgba($color: #000000, $alpha: .1);
color: rgba($color: white, $alpha: .7);
display: inline-block;
font-size: 24rpx;
padding: 6rpx $padding;
border-radius: $radius-m;
border: solid 1rpx rgba($color: white, $alpha: .4)
}
.balance-flex {
display: flex;
justify-content: center;
margin-top: $margin * 2;
.balance-flex-item {
background-color: white;
width: 200rpx;
height: 75rpx;
line-height: 75rpx;
color: $text-price;
margin: 0 $margin;
border-radius: $radius-m;
font-size: 28rpx;
}
}
}
}
// 记录
.record {
background-color: white;
border-radius: $radius $radius 0 0;
padding: $padding ($padding * 2);
margin-top: -$margin;
position: relative;
z-index: 2;
.record-tabs {
display: flex;
justify-content: space-around;
font-weight: bold;
font-size: $title-size;
color: $text-gray;
line-height: 70rpx;
margin-bottom: $margin;
.tabs-item {
position: relative;
padding: 0 $padding;
&.show {
color: $text-price;
&::before {
position: absolute;
bottom: 0;
left: $padding;
right: $padding;
height: 4rpx;
content: " ";
background-color: $text-price;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,150 @@
<template>
<view>
<!-- 设置钱包密码 -->
<view class="password">
<view class="prompt">请设置6位数字密码建议不要使用连续的数字</view>
<view class="group">
<view class="inputs">
<label>密码</label>
<input type="digit" v-model="password" maxlength="6" password placeholder="请设置新密码" />
</view>
<view class="inputs">
<label>确认密码</label>
<input type="digit" v-model="verify" maxlength="6" password placeholder="请确认新密码" />
</view>
</view>
</view>
<!-- 按钮 -->
<view class="buttons">
<button type="default" form-type="submit" @click="createWallet">确认</button>
</view>
</view>
</template>
<script>
import {
securityReset
} from '@/apis/interfaces/wallet'
export default {
data() {
return {
password: '',
verify: '',
oldPassword: ''
}
},
onLoad() {
this.oldPassword = this.$Route.query.password
},
methods: {
// 激活钱包
createWallet() {
if (this.password === '' || this.verify === '') {
uni.showToast({
icon: 'none',
title: '请设置密码'
})
return
}
if (this.password !== this.verify) {
uni.showToast({
icon: 'none',
title: '两次输入密码不一致'
})
return
}
securityReset({
new_code: this.password,
old_code: this.oldPassword
}).then(res => {
uni.showModal({
title: '提示',
content: '密码已重置',
showCancel:false,
success: res=> {
uni.navigateBack()
}
})
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
}
}
}
</script>
<style lang="scss" scoped>
// 副标题
.sub-title {
color: $text-gray;
text-align: center;
margin: $margin * 2 $margin;
font-size: $title-size-m;
}
// 设置密码
.password {
padding: 0 $padding * 2;
.prompt {
margin-top: $margin * 2;
font-size: $title-size-m;
color: $mian-color;
}
.group {
margin-top: $margin;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
.inputs {
padding: $padding $padding + 10;
border-bottom: solid 1rpx $border-color;
&:last-child {
border-bottom: none;
}
label {
color: $text-gray;
font-size: $title-size-m;
}
input {
height: 70rpx;
line-height: 70rpx;
font-size: $title-size;
}
}
}
}
// 按钮
.buttons {
padding: $padding * 2;
.text {
text-align: center;
line-height: 90rpx;
height: 90rpx;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $mian-color;
font-weight: bold;
}
button {
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
}
}
</style>

77
pages/wallet/results.vue Normal file
View File

@@ -0,0 +1,77 @@
<template>
<view>
<view class="webkit-box results">
<uni-icons type="checkbox-filled" size="88" color="#009b69"></uni-icons>
<view class="title">交易已提交</view>
<view class="sub-title">预计10秒内到账可在交易记录中查询以实际到账时间为准</view>
<view class="hash">
<view class="hash-title">交易哈希</view>
<view class="hash-text">{{hash}}</view>
</view>
<button class="results-button" type="default" @click="navBack">返回</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
hash: ''
};
},
onLoad(e){
this.hash = e.hash
},
methods:{
navBack(){
uni.navigateBack()
}
}
}
</script>
<style lang="scss" scoped>
.results{
height: 100vh;
box-sizing: border-box;
text-align: center;
padding-left: $padding * 3;
padding-right: $padding * 3;
padding-bottom: 20vh;
.title{
font-size: $title-size + 8;
color: $text-color;
font-weight: bold;
line-height: 80rpx;
padding: $padding 0;
}
.sub-title{
color: $text-gray;
line-height: 40rpx;
}
.hash{
background-color: white;
padding: $padding * 2;
border-radius: $radius-lg;
margin-top: $margin * 2;
font-size: $title-size;
color: $text-color;
.hash-title{
padding-bottom: $padding;
}
.hash-text{
word-break:break-all;
}
}
.results-button{
margin-top: $margin * 3;
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
color: white;
font-size: $title-size;
font-weight: bold;
}
}
</style>

216
pages/wallet/transfer.vue Normal file
View File

@@ -0,0 +1,216 @@
<template>
<view>
<!-- 账户余额 -->
<view class="transfer-block">
<view class="unit">OCC</view>
<view class="transfer-flex">
<view class="item ellipsis">
<label>数量</label>{{balance.balance || '0.00'}}
</view>
<view class="item ellipsis">
<label>估值(CNY)</label>{{cny || '0.00'}}
</view>
</view>
</view>
<view class="sub-title">
<text>请认真确认地址及数量地址错误无法找回</text>
</view>
<!-- 转账信息 -->
<view class="password">
<view class="group">
<view class="inputs input-scan">
<label>接收地址</label>
<input type="text" placeholder="请输入接收地址" v-model="address" />
<view class="input-scan-icon" @click="scanCode">
<uni-icons type="scan" size="22" color="#009b69"></uni-icons>
</view>
</view>
<view class="inputs">
<label>转账数量</label>
<input type="number" placeholder="请输入转账数量" v-model="number" />
</view>
</view>
<view class="group">
<view class="inputs">
<label>交易密码</label>
<input type="password" placeholder="请输入安全密码" v-model="password" />
</view>
</view>
</view>
<!-- 按钮 -->
<view class="buttons">
<button type="default" @click="submitTransfer">转账</button>
</view>
</view>
</template>
<script>
import { sum, price, transfer } from '@/apis/interfaces/wallet'
export default {
data() {
return {
balance: {},
cny: '0.00',
address: '',
number: '',
password: ''
}
},
onLoad(e){
if(e.hashAddress) this.address = e.hashAddress
},
mounted() {
Promise.all([
sum(),
price()
]).then(res => {
this.balance = res[0]
if (res[0].balance > 0) this.cny = (res[1] * res[0].balance).toFixed(2)
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
},
methods: {
// 转账
submitTransfer(){
if(this.address === '' || this.number === '' || this.password === ''){
let messageText
if(this.address === '') messageText = '请输入接收地址'
else if(this.number === '') messageText = '请输入转账数量'
else if(this.password === '') messageText = '请输入安全密码'
uni.showToast({
icon: 'none',
title: messageText
})
return
}
// 提交转账信息
transfer({
to: this.address,
amount: this.number,
security_code: this.password
}).then(res => {
uni.redirectTo({
url: './results?hash=' + res.txHash + '&number=' + this.number
})
}).catch(err => {
uni.showToast({
icon: 'none',
title: err.message
})
})
},
// 扫码
scanCode(){
uni.scanCode({
scanType: ['qrCode'],
success: res=> {
this.address = res.result
}
})
}
}
}
</script>
<style lang="scss" scoped>
// 账户余额
.transfer-block{
background-color: white;
margin: $margin * 2;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
padding: $padding $padding + 10;
.unit{
font-weight: bold;
font-size: $title-size + 10;
line-height: 90rpx;
color: $text-color;
}
.transfer-flex{
display: flex;
padding: $padding 0;
border-top: solid 1rpx $border-color;
.item{
width: 50%;
font-size: $title-size-m;
& > label{
color: $text-gray;
padding-right: $padding/2;
}
}
}
}
// 提示信息
.sub-title{
color: $text-gray;
text-align: center;
margin: $margin * 2 $margin;
font-size: $title-size-m;
}
// 转账信息
.password{
padding: 0 $padding * 2;
.group{
margin-top: $margin;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
.inputs{
padding: $padding $padding + 10;
border-bottom: solid 1rpx $border-color;
&:last-child{
border-bottom: none;
}
label{
color: $text-gray;
font-size: $title-size-m;
}
input{
height: 70rpx;
line-height: 70rpx;
font-size: $title-size;
}
}
.input-scan{
position: relative;
padding-right: ($padding*2) + 70;
.input-scan-icon{
position: absolute;
bottom: $padding;
right: $padding;
height: 70rpx;
width: 70rpx;
line-height: 70rpx;
text-align: center;
}
}
}
}
// 按钮
.buttons{
padding: $padding * 2;
.text{
text-align: center;
line-height: 90rpx;
height: 90rpx;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $mian-color;
font-weight: bold;
}
button{
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
}
}
</style>

169
pages/wallet/validation.vue Normal file
View File

@@ -0,0 +1,169 @@
<template>
<view>
<!-- 提示信息 -->
<view class="prompt">
验证您的钱包助记词
</view>
<!-- 助记词 -->
<view class="mnemonic">
<view
class="item"
v-for="(item, index) in validation"
:key="index"
:class="item === null ? 'hide': ''"
@click="onKeys('removeKey', index)"
>{{ item }}</view>
</view>
<!-- 选择助记词 -->
<block v-if="mnemonic.length > 0">
<view class="mnemonic-title">
按顺序填写助记词
</view>
<view class="mnemonic-select">
<view class="item" v-for="(item, index) in mnemonic" :key="index" @click="onKeys('addKey', index)">{{ item }}</view>
</view>
</block>
<!-- 按钮 -->
<view class="buttons">
<button type="default" @click="verifyMnemonic">验证</button>
</view>
</view>
</template>
<script>
import { hash } from "../../apis/interfaces/wallet"
export default {
data() {
return {
validation : new Array(15).fill(null), // 验证key
mnemonic : [], // 助记词key
sign : '', // 助记词校验签名
seedString : '', // 助记词原词
}
},
onLoad(e) {
let seed = e.seed.split(',')
seed.sort(() => {
return Math.random() - .5
});
this.mnemonic = seed
this.sign = e.sign
this.seedString = e.seed
},
methods: {
// 填写助记词
onKeys(type, index){
if(type === 'addKey') {
this.$set(this.validation, this.validation.findIndex(val => val === null), this.mnemonic[index])
this.$delete(this.mnemonic, index)
return
}
if(type === 'removeKey' && this.validation[index] !== null) {
this.mnemonic.push(this.validation[index])
this.$delete(this.validation, index)
this.validation.push(null)
}
},
// 验证助记词
verifyMnemonic(){
if(this.validation.findIndex(val => val === null) > -1){
uni.showToast({
title: '请完整填写助记词',
icon : 'none'
})
return
}
let seed = this.validation.toString().replace(/,/g, ',')
if (this.seedString !== seed) {
uni.showToast({
title: '验证失败,请确认您的助记词',
icon : 'none'
})
return
}
uni.redirectTo({
url: './create'
})
}
}
}
</script>
<style lang="scss" scoped>
// 提示信息
.prompt{
color: $text-gray;
text-align: center;
line-height: 90rpx;
font-size: $title-size-m;
}
// 选择助记词
.mnemonic-title{
padding-top: $padding * 2;
margin: 0 $margin * 2;
font-size: $title-size-m;
color: $mian-color;
}
.mnemonic-select{
display: flex;
flex-wrap: wrap;
padding: $padding $padding + $padding / 2;
.item{
background-color: white;
line-height: 68rpx;
height: 68rpx;
width: 68rpx;
text-align: center;
margin: $margin / 2;
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
}
}
// 助记词
.mnemonic{
margin: $margin ($margin * 2);
border-radius: $radius-m;
box-shadow: 0 0 4rpx 4rpx rgba($color: $text-color, $alpha: .02);
background-color: white;
padding: $padding;
display: flex;
flex-wrap: wrap;
align-items: flex-start;
.item{
background: rgba($color: $border-color, $alpha: .4);
width: 58rpx;
height: 58rpx;
line-height: 58rpx;
text-align: center;
color: $text-color;
margin: $margin / 2;
&.hide{
border:dashed 1px $border-color;
box-sizing: border-box;
background-color: white;
}
}
}
// 按钮
.buttons{
padding: $padding $padding * 2;
.text{
text-align: center;
margin-bottom: $margin * 2;
font-size: $title-size-lg;
color: $red-color;
}
button{
height: 90rpx;
line-height: 90rpx;
background-color: $mian-color;
border-radius: $radius-lg;
color: white;
font-weight: bold;
font-size: $title-size;
&[disabled]{
background: rgba($color: $mian-color, $alpha: .8);
}
}
}
</style>

View File

@@ -10,9 +10,12 @@ $text-color: #333;
$text-gray: #555;
$text-gray-m: #999;
$text-price: #8b64fd;
$mian-color: #b11eff;
$mian-color: #8b64fd;
$mian-color-deep: #824f9a;
// 矿机
$block-color: #2b2449;
// 边框颜色
$border-color: #ddd;
$border-color-lg: #eff4f2;
@@ -76,20 +79,6 @@ $padding: 30rpx;
-webkit-line-clamp: 2;
}
.ellipsis {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.ellipsis-2 {
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.ellipsis-3 {
display: -webkit-box;
overflow: hidden;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 482 KiB

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
static/icons/logs-null.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
static/imgs/account-bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
static/imgs/cart_empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
static/imgs/news_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
static/imgs/news_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
static/imgs/news_2_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

BIN
static/imgs/news_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
static/imgs/news_3_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

BIN
static/imgs/record-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -0,0 +1,27 @@
## 1.3.32021-08-17
- 优化 show-arrow 属性默认为true
## 1.3.22021-08-17
- 新增 show-arrow 属性,控制是否显示右侧箭头
## 1.3.12021-07-30
- 优化 vue3下小程序事件警告的问题
## 1.3.02021-07-30
- 组件兼容 vue3如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 1.2.22021-07-21
- 修复 由1.2.0版本引起的 change 事件返回 undefined 的Bug
## 1.2.12021-07-21
- 优化 组件示例
## 1.2.02021-07-21
- 新增 组件折叠动画
- 新增 value\v-model 属性 ,动态修改面板折叠状态
- 新增 title 插槽 ,可定义面板标题
- 新增 border 属性 ,显示隐藏面板内容分隔线
- 新增 title-border 属性 ,显示隐藏面板标题分隔线
- 修复 resize 方法失效的Bug
- 修复 change 事件返回参数不正确的Bug
- 优化 H5、App 平台自动更具内容更新高度,无需调用 reszie() 方法
## 1.1.72021-05-12
- 新增 组件示例地址
## 1.1.62021-02-05
- 优化 组件引用关系通过uni_modules引用组件
## 1.1.52021-02-05
- 调整为uni_modules目录规范

View File

@@ -0,0 +1,402 @@
<template>
<view class="uni-collapse-item">
<!-- onClick(!isOpen) -->
<view @click="onClick(!isOpen)" class="uni-collapse-item__title"
:class="{'is-open':isOpen &&titleBorder === 'auto' ,'uni-collapse-item-border':titleBorder !== 'none'}">
<view class="uni-collapse-item__title-wrap">
<slot name="title">
<view class="uni-collapse-item__title-box" :class="{'is-disabled':disabled}">
<image v-if="thumb" :src="thumb" class="uni-collapse-item__title-img" />
<text class="uni-collapse-item__title-text">{{ title }}</text>
</view>
</slot>
</view>
<view
v-if="showArrow"
:class="{ 'uni-collapse-item__title-arrow-active': isOpen, 'uni-collapse-item--animation': showAnimation === true }"
class="uni-collapse-item__title-arrow">
<uni-icons :color="disabled?'#ddd':'#bbb'" size="14" type="arrowdown" />
</view>
</view>
<view class="uni-collapse-item__wrap" :class="{'is--transition':showAnimation}"
:style="{height: (isOpen?height:0) +'px'}">
<view :id="elId" ref="collapse--hook" class="uni-collapse-item__wrap-content"
:class="{open:isheight,'uni-collapse-item--border':border&&isOpen}">
<slot></slot>
</view>
</view>
</view>
</template>
<script>
// #ifdef APP-NVUE
const dom = weex.requireModule('dom')
// #endif
/**
* CollapseItem 折叠面板子组件
* @description 折叠面板子组件
* @property {String} title 标题文字
* @property {String} thumb 标题左侧缩略图
* @property {String} name 唯一标志符
* @property {Boolean} open = [true|false] 是否展开组件
* @property {Boolean} titleBorder = [true|false] 是否显示标题分隔线
* @property {Boolean} border = [true|false] 是否显示分隔线
* @property {Boolean} disabled = [true|false] 是否展开面板
* @property {Boolean} showAnimation = [true|false] 开启动画
* @property {Boolean} showArrow = [true|false] 是否显示右侧箭头
*/
export default {
name: 'uniCollapseItem',
props: {
// 列表标题
title: {
type: String,
default: ''
},
name: {
type: [Number, String],
default: ''
},
// 是否禁用
disabled: {
type: Boolean,
default: false
},
// #ifdef APP-PLUS
// 是否显示动画,app 端默认不开启动画,卡顿严重
showAnimation: {
type: Boolean,
default: false
},
// #endif
// #ifndef APP-PLUS
// 是否显示动画
showAnimation: {
type: Boolean,
default: true
},
// #endif
// 是否展开
open: {
type: Boolean,
default: false
},
// 缩略图
thumb: {
type: String,
default: ''
},
// 标题分隔线显示类型
titleBorder: {
type: String,
default: 'auto'
},
border: {
type: Boolean,
default: true
},
showArrow:{
type: Boolean,
default: true
}
},
data() {
// TODO 随机生生元素ID解决百度小程序获取同一个元素位置信息的bug
const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`
return {
isOpen: false,
isheight: null,
height: 0,
elId,
nameSync: 0
}
},
watch: {
open(val) {
this.isOpen = val
this.onClick(val,'init')
}
},
updated(e) {
this.$nextTick(()=> {
this.init(true)
})
},
created(){
this.collapse = this.getCollapse()
this.oldHeight = 0
},
// #ifndef VUE3
// TODO vue2
destroyed() {
if (this.__isUnmounted) return
this.uninstall()
},
// #endif
// #ifdef VUE3
// TODO vue3
unmounted() {
this.__isUnmounted = true
this.uninstall()
},
// #endif
mounted() {
if (!this.collapse) return
if (this.name !== '') {
this.nameSync = this.name
} else {
this.nameSync = this.collapse.childrens.length + ''
}
if (this.collapse.names.indexOf(this.nameSync) === -1) {
this.collapse.names.push(this.nameSync)
} else {
console.warn(`name 值 ${this.nameSync} 重复`);
}
if (this.collapse.childrens.indexOf(this) === -1) {
this.collapse.childrens.push(this)
}
this.init()
},
methods: {
init(type) {
// #ifndef APP-NVUE
this.getCollapseHeight(type)
// #endif
// #ifdef APP-NVUE
this.getNvueHwight(type)
// #endif
},
uninstall() {
if (this.collapse) {
this.collapse.childrens.forEach((item, index) => {
if (item === this) {
this.collapse.childrens.splice(index, 1)
}
})
this.collapse.names.forEach((item, index) => {
if (item === this.nameSync) {
this.collapse.names.splice(index, 1)
}
})
}
},
onClick(isOpen,type) {
if (this.disabled) return
this.isOpen = isOpen
if (this.isOpen && this.collapse) {
this.collapse.setAccordion(this)
}
if(type !== 'init'){
this.collapse.onChange(isOpen,this)
}
},
getCollapseHeight(type, index = 0) {
const views = uni.createSelectorQuery().in(this)
views
.select(`#${this.elId}`)
.fields({
size: true
}, data => {
// TODO 百度中可能获取不到节点信息 ,需要循环获取
if (index >= 10) return
if (!data) {
index++
this.getCollapseHeight(false, index)
return
}
// #ifdef APP-NVUE
this.height = data.height + 1
// #endif
// #ifndef APP-NVUE
this.height = data.height
// #endif
this.isheight = true
if (type) return
this.onClick(this.open,'init')
})
.exec()
},
getNvueHwight(type) {
const result = dom.getComponentRect(this.$refs['collapse--hook'], option => {
if (option && option.result && option.size) {
// #ifdef APP-NVUE
this.height = option.size.height + 1
// #endif
// #ifndef APP-NVUE
this.height = option.size.height
// #endif
this.isheight = true
if (type) return
this.onClick(this.open,'init')
}
})
},
/**
* 获取父元素实例
*/
getCollapse(name = 'uniCollapse') {
let parent = this.$parent;
let parentName = parent.$options.name;
while (parentName !== name) {
parent = parent.$parent;
if (!parent) return false;
parentName = parent.$options.name;
}
return parent;
}
}
}
</script>
<style lang="scss" scoped>
.uni-collapse-item {
/* #ifndef APP-NVUE */
box-sizing: border-box;
/* #endif */
&__title {
/* #ifndef APP-NVUE */
display: flex;
width: 100%;
box-sizing: border-box;
/* #endif */
flex-direction: row;
align-items: center;
transition: border-bottom-color .3s;
// transition-property: border-bottom-color;
// transition-duration: 5s;
&-wrap {
width: 100%;
flex: 1;
}
&-box {
padding: 0 15px;
/* #ifndef APP-NVUE */
display: flex;
width: 100%;
box-sizing: border-box;
/* #endif */
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 48px;
line-height: 48px;
background-color: #fff;
color: #303133;
font-size: 13px;
font-weight: 500;
/* #ifdef H5 */
cursor: pointer;
outline: none;
/* #endif */
&.is-disabled {
.uni-collapse-item__title-text {
color: $uni-text-color-disable;
}
}
}
&.uni-collapse-item-border {
border-bottom: 1px solid #ebeef5;
}
&.is-open {
border-bottom-color: transparent;
}
&-img {
height: $uni-img-size-base;
width: $uni-img-size-base;
margin-right: 10px;
}
&-text {
flex: 1;
font-size: $uni-font-size-base;
/* #ifndef APP-NVUE */
white-space: nowrap;
color: inherit;
/* #endif */
/* #ifdef APP-NVUE */
lines: 1;
/* #endif */
overflow: hidden;
text-overflow: ellipsis;
}
&-arrow {
/* #ifndef APP-NVUE */
display: flex;
box-sizing: border-box;
/* #endif */
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
margin-right: 10px;
transform: rotate(0deg);
&-active {
transform: rotate(180deg);
}
}
}
&__wrap {
/* #ifndef APP-NVUE */
will-change: height;
box-sizing: border-box;
/* #endif */
background-color: #fff;
overflow: hidden;
position: relative;
height: 0;
&.is--transition {
// transition: all 0.3s;
transition-property: height, border-bottom-width;
transition-duration: 0.3s;
/* #ifndef APP-NVUE */
will-change: height;
/* #endif */
}
&-content {
position: absolute;
font-size: 13px;
color: #303133;
// transition: height 0.3s;
border-bottom-color: transparent;
border-bottom-style: solid;
border-bottom-width: 0;
&.uni-collapse-item--border {
border-bottom-width: 1px;
border-bottom-color: red;
border-bottom-color: #ebeef5;
}
&.open {
position: relative;
}
}
}
&--animation {
transition-property: transform;
transition-duration: 0.3s;
transition-timing-function: ease;
}
}
</style>

View File

@@ -0,0 +1,146 @@
<template>
<view class="uni-collapse">
<slot />
</view>
</template>
<script>
/**
* Collapse 折叠面板
* @description 展示可以折叠 / 展开的内容区域
* @tutorial https://ext.dcloud.net.cn/plugin?id=23
* @property {String|Array} value 当前激活面板改变时触发(如果是手风琴模式参数类型为string否则为array)
* @property {Boolean} accordion = [true|false] 是否开启手风琴效果是否开启手风琴效果
* @event {Function} change 切换面板时触发如果是手风琴模式返回类型为string否则为array
*/
export default {
name: 'uniCollapse',
emits:['change','activeItem','input','update:modelValue'],
props: {
value: {
type: [String, Array],
default: ''
},
modelValue: {
type: [String, Array],
default: ''
},
accordion: {
// 是否开启手风琴效果
type: [Boolean, String],
default: false
},
},
data() {
return {}
},
computed: {
// TODO 兼容 vue2 和 vue3
dataValue() {
let value = (typeof this.value === 'string' && this.value === '') ||
(Array.isArray(this.value) && this.value.length === 0)
let modelValue = (typeof this.modelValue === 'string' && this.modelValue === '') ||
(Array.isArray(this.modelValue) && this.modelValue.length === 0)
if (value) {
return this.modelValue
}
if (modelValue) {
return this.value
}
return this.value
}
},
watch: {
dataValue(val) {
this.setOpen(val)
}
},
created() {
this.childrens = []
this.names = []
},
mounted() {
this.setOpen(this.dataValue)
},
methods: {
setOpen(val) {
let str = typeof val === 'string'
let arr = Array.isArray(val)
this.childrens.forEach((vm, index) => {
if (str) {
if (val === vm.nameSync) {
if (!this.accordion) {
console.warn('accordion 属性为 false ,v-model 类型应该为 array')
return
}
vm.isOpen = true
}
}
if (arr) {
val.forEach(v => {
if (v === vm.nameSync) {
if (this.accordion) {
console.warn('accordion 属性为 true ,v-model 类型应该为 string')
return
}
vm.isOpen = true
}
})
}
})
this.emit(val)
},
setAccordion(self) {
if (!this.accordion) return
this.childrens.forEach((vm, index) => {
if (self !== vm) {
vm.isOpen = false
}
})
},
resize() {
this.childrens.forEach((vm, index) => {
// #ifndef APP-NVUE
vm.getCollapseHeight()
// #endif
// #ifdef APP-NVUE
vm.getNvueHwight()
// #endif
})
},
onChange(isOpen, self) {
let activeItem = []
if (this.accordion) {
activeItem = isOpen ? self.nameSync : ''
} else {
this.childrens.forEach((vm, index) => {
if (vm.isOpen) {
activeItem.push(vm.nameSync)
}
})
}
this.$emit('change', activeItem)
this.emit(activeItem)
},
emit(val){
this.$emit('input', val)
this.$emit('update:modelValue', val)
}
}
}
</script>
<style lang="scss" scoped>
.uni-collapse {
/* #ifndef APP-NVUE */
width: 100%;
display: flex;
/* #endif */
/* #ifdef APP-NVUE */
flex: 1;
/* #endif */
flex-direction: column;
background-color: $uni-bg-color;
}
</style>

View File

@@ -0,0 +1,88 @@
{
"id": "uni-collapse",
"displayName": "uni-collapse 折叠面板",
"version": "1.3.3",
"description": "Collapse 组件,可以折叠 / 展开的内容区域。",
"keywords": [
"uni-ui",
"折叠",
"折叠面板",
"手风琴"
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
"HBuilderX": ""
},
"directories": {
"example": "../../temps/example_temps"
},
"dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
},
"uni_modules": {
"dependencies": [
"uni-icons"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "u"
}
}
}
}
}

View File

@@ -0,0 +1,276 @@
## Collapse 折叠面板
> **组件名uni-collapse**
> 代码块: `uCollapse`
> 关联组件:`uni-collapse-item`、`uni-icons`。
折叠面板用来折叠/显示过长的内容或者是列表。通常是在多内容分类项使用,折叠不重要的内容,显示重要内容。点击可以展开折叠部分。
> **注意事项**
> 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。
> - 组件需要依赖 `sass` 插件 ,请自行手动安装
> - `App` 端默认关闭组件动画 ,因为 `height` 动画开销比较大,会导致页面卡顿,请酌情使用动画
> - 如在使用组件过程从发现卡顿严重,请尝试停用组件动画,问题原因如上
> - 在小程序端组件内容发生变化,需要手动调用 resize() 方法,手动更新几点信息,避免出现内容错位
> - 如需自定义组件默认边框颜色等,请使用插槽自定义内容并合理使用 `border ` 和 `title-border` 属性
> - 折叠面板仅支持嵌套使用,请勿单独使用
> - 组件支持 nvue ,需要在 `manifest.json > app-plus` 节点下配置 `"nvueStyleCompiler" : "uni-app"`
> - 如使用过程中有任何问题或者您对uni-ui有一些好的建议欢迎加入 uni-ui 交流群871950839
### 安装方式
本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`
如需通过`npm`方式使用`uni-ui`组件,另见文档:[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55)
### 基本用法
使用 `title` 属性指定面板显示内容
使用 `open` 属性默认打开当前面板
使用 `disabled` 属性禁用面板
```html
<uni-collapse>
<uni-collapse-item title="默认开启" :open="true">
<text>折叠内容</text>
</uni-collapse-item>
<uni-collapse-item title="折叠内容">
<text>折叠内容</text>
</uni-collapse-item>
<uni-collapse-item title="禁用状态" disabled>
<text>折叠内容</text>
</uni-collapse-item>
</uni-collapse>
```
### 手风琴效果
使用 `accordion` 属性,可以仅打开一个面板并关闭其他已经打开的面板,效果类似手风琴
设置 `accordion` 属性时,`open` 属性则生效在最后一个组件
```html
<uni-collapse accordion>
<uni-collapse-item title="手风琴效果">
<text>折叠内容</text>
</uni-collapse-item>
<uni-collapse-item title="手风琴效果">
<text>折叠内容</text>
</uni-collapse-item>
<uni-collapse-item title="禁用状态" disabled>
<text>折叠内容</text>
</uni-collapse-item>
</uni-collapse>
```
### 动态设置折叠面板打开状态
使用 `v-model` 属性,动态设置面板的显示状态
使用 `name` 属性设置每个面板的唯一标识,如不设置使用默认索引,从字符串 `"0"` 开始记数
**注意**
- 如果 `accordion` 属性为 `true``v-model` 类型为 `String`
- 如果 `accordion` 属性为 `false``v-model` 类型为 `Array`
- 请注意 `v-model` 属性与 `open` 属性请勿一起使用 ,建议只使用 `v-model`
```html
<uni-collapse v-model="value">
<uni-collapse-item name="key1" title="默认开启">
<text>折叠内容</text>
</uni-collapse-item>
<uni-collapse-item name="key2" title="默认开启">
<text>折叠内容</text>
</uni-collapse-item>
<uni-collapse-item name="key3" title="默认不开启">
<text>折叠内容</text>
</uni-collapse-item>
</uni-collapse>
```
```javascript
export default {
data(){
return {
value:['key1','key2'],
// 如果设置了 accordion 属性,则使用 string 类型
// value:'key1'
}
}
}
```
### 使用动画
使用 `show-animation` 属性开启或关闭面板折叠动画,默认动画开启
**注意**
- `App` 端默认关闭组件动画 ,因为 height 动画开销比较大,会导致页面卡顿,请酌情使用动画,如出现明显卡顿,尝试关闭动画
```html
<uni-collapse>
<uni-collapse-item :show-animation="true" title="开启动画">
<text>折叠内容</text>
</uni-collapse-item>
<uni-collapse-item :show-animation="true" title="开启动画">
<text>折叠内容</text>
</uni-collapse-item>
<uni-collapse-item :show-animation="false" title="不开启动画">
<text>折叠内容</text>
</uni-collapse-item>
</uni-collapse>
```
### 配置图片
使用 `thumb` 配置图片地址, 可在面板左侧显示一个图片
如需显示更多内容,如图标等,请见下方自定义插槽的说明
```html
<uni-collapse>
<uni-collapse-item title="标题文字"
thumb="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png">
<view class="content">
<text class="text">折叠内容主体,可自定义内容及样式</text>
</view>
</uni-collapse-item>
</uni-collapse>
```
### 自定义插槽
如果需要自定义面板显示,可以使用 `title` 插槽达成完全自定义。下面是一个使用 `uni-list` 的列表示例,需要引入 `uni-list` 组件
```html
<uni-collapse>
<!-- 因为list默认带一条分隔线所以使用 titleBorder="none" 取消面板的分隔线 -->
<uni-collapse-item title-border="none" :border="false">
<template v-slot:title>
<uni-list>
<uni-list-item title="标题使用自定义标题插槽" :show-extra-icon="true" :extra-icon="extraIcon">
</uni-list-item>
</uni-list>
</template>
<view class="content">
<text class="text">折叠内容主体,可自定义内容及样式</text>
</view>
</uni-collapse-item>
</uni-collapse>
```
**注意**
- 在折叠面板组件中使用list时在 App-Nvue 下请勿单独使用 uni-list-item会导致组件无法正常显示其他平台不做限制
- 在默认插槽里使用 uni-list 组件与上方示例一样,直接写在默认插槽里即可
## API
### Collapse Props
|属性名|类型|默认值|说明|
|:-:|:-:|:-:|:-:|
|value/v-model|String/Array|-|当前激活面板改变时触发(如果是手风琴模式参数类型为string否则为array)|
|accordion|Boolean|false|是否开启手风琴效果 |
### Collapse Event
|事件称名|说明|返回值|
|:-:|:-:|:-:|
|@change|切换面板时触发 |切换面板时触发如果是手风琴模式返回类型为string否则为array|
### Collapse Methods
|方法名称|说明|
|:-:|:-:|
|resize |更新当前列表高度|
> **提示**
> - resize 方法解决动态添加数据,带动画的折叠面板高度不更新的问题
> - 需要在数据渲染完毕之后使用 `resize` 方法。推荐在 `this.$nextTick()` 中使用
> - 当前只有小程序端需要调用此方法H5\App 端已经做了处理,不需要手动更新高度
> ```html
> <view>
> <uni-collapse ref="collapse" v-model="value">
> <uni-collapse-item title="默认开启" >
> <view class="content">
> <text class="text">{{content}}</text>
> </view>
> </uni-collapse-item>
> <uni-collapse-item title="折叠内容">
> <view class="content">
> <text class="text">折叠内容主体,这是一段比较长内容。默认折叠主要内容,只显示当前项标题。点击标题展开,才能看到这段文字。再次点击标题,折叠内容。</text>
> </view>
> </uni-collapse-item>
> </uni-collapse>
> <button class="button" type="primary" @click="add">动态修改内容</button>
> </view>
> ```
> ```javascript
> export default {
> data() {
> return {
> value:['0'],
> content: '折叠内容主体,可自定义内容及样式,点击按钮修改内容使高度发生变化。',
> }
> },
> methods: {
> add() {
> if (this.content.length > 35) {
> this.content = '折叠内容主体,可自定义内容及样式,点击按钮修改内容使高度发生变化。'
> } else {
> this.content = '折叠内容主体,这是一段比较长内容。通过点击按钮修改后内容后,使组件高度发生变化,在次点击按钮恢复之前的内容和高度。'
> }
> // TODO 小程序中不支持自动更新 需要手动resize 更新组件高度
> // #ifdef MP
> this.$nextTick(() => {
> this.$refs.collapse.resize()
> })
> // #endif
> }
> }
> }
> ```
### CollapseItem Props
|属性名|类型|默认值|说明|
|:-:|:-:|:-:|:-:|
|title|String|-|标题文字|
|thumb|String|-|标题左侧缩略图|
|disabled|Boolean|false|是否禁用|
|open|Boolean|false|是否展开面板|
|show-animation|Boolean|false|开启动画|
|border|Boolean|true|折叠面板内容分隔线|
|title-border|String|auto|折叠面板标题分隔线可选值见下方 **TitleBorder Params**|
|show-arrow|Boolean|true|是否显示右侧箭头|
#### TitleBorder Params
|参数名|说明|
|:-:|:-:|
|auto|分隔线自动显示|
|none|不显示分隔线|
|show|一直显示分隔线|
### Collapse Slots
|插槽名|说明|
|:-:| :-:|
|default|默认插槽|
|title|面板标题插槽,如使用此插槽禁用样式效果将失效|
## 组件示例
点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/collapse/collapse](https://hellouniapp.dcloud.net.cn/pages/extUI/collapse/collapse)

View File

@@ -1,132 +1,132 @@
export default {
"pulldown": "\ue588",
"refreshempty": "\ue461",
"back": "\ue471",
"forward": "\ue470",
"more": "\ue507",
"more-filled": "\ue537",
"scan": "\ue612",
"qq": "\ue264",
"weibo": "\ue260",
"weixin": "\ue261",
"pengyouquan": "\ue262",
"loop": "\ue565",
"refresh": "\ue407",
"refresh-filled": "\ue437",
"arrowthindown": "\ue585",
"arrowthinleft": "\ue586",
"arrowthinright": "\ue587",
"arrowthinup": "\ue584",
"undo-filled": "\ue7d6",
"undo": "\ue406",
"redo": "\ue405",
"redo-filled": "\ue7d9",
"bars": "\ue563",
"chatboxes": "\ue203",
"camera": "\ue301",
"chatboxes-filled": "\ue233",
"camera-filled": "\ue7ef",
"cart-filled": "\ue7f4",
"cart": "\ue7f5",
"checkbox-filled": "\ue442",
"checkbox": "\ue7fa",
"arrowleft": "\ue582",
"arrowdown": "\ue581",
"arrowright": "\ue583",
"smallcircle-filled": "\ue801",
"arrowup": "\ue580",
"circle": "\ue411",
"eye-filled": "\ue568",
"eye-slash-filled": "\ue822",
"eye-slash": "\ue823",
"eye": "\ue824",
"flag-filled": "\ue825",
"flag": "\ue508",
"gear-filled": "\ue532",
"reload": "\ue462",
"gear": "\ue502",
"hand-thumbsdown-filled": "\ue83b",
"hand-thumbsdown": "\ue83c",
"hand-thumbsup-filled": "\ue83d",
"heart-filled": "\ue83e",
"hand-thumbsup": "\ue83f",
"heart": "\ue840",
"home": "\ue500",
"info": "\ue504",
"home-filled": "\ue530",
"info-filled": "\ue534",
"circle-filled": "\ue441",
"chat-filled": "\ue847",
"chat": "\ue263",
"mail-open-filled": "\ue84d",
"email-filled": "\ue231",
"mail-open": "\ue84e",
"email": "\ue201",
"checkmarkempty": "\ue472",
"list": "\ue562",
"locked-filled": "\ue856",
"locked": "\ue506",
"map-filled": "\ue85c",
"map-pin": "\ue85e",
"map-pin-ellipse": "\ue864",
"map": "\ue364",
"minus-filled": "\ue440",
"mic-filled": "\ue332",
"minus": "\ue410",
"micoff": "\ue360",
"mic": "\ue302",
"clear": "\ue434",
"smallcircle": "\ue868",
"close": "\ue404",
"closeempty": "\ue460",
"paperclip": "\ue567",
"paperplane": "\ue503",
"paperplane-filled": "\ue86e",
"person-filled": "\ue131",
"contact-filled": "\ue130",
"person": "\ue101",
"contact": "\ue100",
"images-filled": "\ue87a",
"phone": "\ue200",
"images": "\ue87b",
"image": "\ue363",
"image-filled": "\ue877",
"location-filled": "\ue333",
"location": "\ue303",
"plus-filled": "\ue439",
"plus": "\ue409",
"plusempty": "\ue468",
"help-filled": "\ue535",
"help": "\ue505",
"navigate-filled": "\ue884",
"navigate": "\ue501",
"mic-slash-filled": "\ue892",
"search": "\ue466",
"settings": "\ue560",
"sound": "\ue590",
"sound-filled": "\ue8a1",
"spinner-cycle": "\ue465",
"download-filled": "\ue8a4",
"personadd-filled": "\ue132",
"videocam-filled": "\ue8af",
"personadd": "\ue102",
"upload": "\ue402",
"upload-filled": "\ue8b1",
"starhalf": "\ue463",
"star-filled": "\ue438",
"star": "\ue408",
"trash": "\ue401",
"phone-filled": "\ue230",
"compose": "\ue400",
"videocam": "\ue300",
"trash-filled": "\ue8dc",
"download": "\ue403",
"chatbubble-filled": "\ue232",
"chatbubble": "\ue202",
"cloud-download": "\ue8e4",
"cloud-upload-filled": "\ue8e5",
"cloud-upload": "\ue8e6",
export default {
"pulldown": "\ue588",
"refreshempty": "\ue461",
"back": "\ue471",
"forward": "\ue470",
"more": "\ue507",
"more-filled": "\ue537",
"scan": "\ue612",
"qq": "\ue264",
"weibo": "\ue260",
"weixin": "\ue261",
"pengyouquan": "\ue262",
"loop": "\ue565",
"refresh": "\ue407",
"refresh-filled": "\ue437",
"arrowthindown": "\ue585",
"arrowthinleft": "\ue586",
"arrowthinright": "\ue587",
"arrowthinup": "\ue584",
"undo-filled": "\ue7d6",
"undo": "\ue406",
"redo": "\ue405",
"redo-filled": "\ue7d9",
"bars": "\ue563",
"chatboxes": "\ue203",
"camera": "\ue301",
"chatboxes-filled": "\ue233",
"camera-filled": "\ue7ef",
"cart-filled": "\ue7f4",
"cart": "\ue7f5",
"checkbox-filled": "\ue442",
"checkbox": "\ue7fa",
"arrowleft": "\ue582",
"arrowdown": "\ue581",
"arrowright": "\ue583",
"smallcircle-filled": "\ue801",
"arrowup": "\ue580",
"circle": "\ue411",
"eye-filled": "\ue568",
"eye-slash-filled": "\ue822",
"eye-slash": "\ue823",
"eye": "\ue824",
"flag-filled": "\ue825",
"flag": "\ue508",
"gear-filled": "\ue532",
"reload": "\ue462",
"gear": "\ue502",
"hand-thumbsdown-filled": "\ue83b",
"hand-thumbsdown": "\ue83c",
"hand-thumbsup-filled": "\ue83d",
"heart-filled": "\ue83e",
"hand-thumbsup": "\ue83f",
"heart": "\ue840",
"home": "\ue500",
"info": "\ue504",
"home-filled": "\ue530",
"info-filled": "\ue534",
"circle-filled": "\ue441",
"chat-filled": "\ue847",
"chat": "\ue263",
"mail-open-filled": "\ue84d",
"email-filled": "\ue231",
"mail-open": "\ue84e",
"email": "\ue201",
"checkmarkempty": "\ue472",
"list": "\ue562",
"locked-filled": "\ue856",
"locked": "\ue506",
"map-filled": "\ue85c",
"map-pin": "\ue85e",
"map-pin-ellipse": "\ue864",
"map": "\ue364",
"minus-filled": "\ue440",
"mic-filled": "\ue332",
"minus": "\ue410",
"micoff": "\ue360",
"mic": "\ue302",
"clear": "\ue434",
"smallcircle": "\ue868",
"close": "\ue404",
"closeempty": "\ue460",
"paperclip": "\ue567",
"paperplane": "\ue503",
"paperplane-filled": "\ue86e",
"person-filled": "\ue131",
"contact-filled": "\ue130",
"person": "\ue101",
"contact": "\ue100",
"images-filled": "\ue87a",
"phone": "\ue200",
"images": "\ue87b",
"image": "\ue363",
"image-filled": "\ue877",
"location-filled": "\ue333",
"location": "\ue303",
"plus-filled": "\ue439",
"plus": "\ue409",
"plusempty": "\ue468",
"help-filled": "\ue535",
"help": "\ue505",
"navigate-filled": "\ue884",
"navigate": "\ue501",
"mic-slash-filled": "\ue892",
"search": "\ue466",
"settings": "\ue560",
"sound": "\ue590",
"sound-filled": "\ue8a1",
"spinner-cycle": "\ue465",
"download-filled": "\ue8a4",
"personadd-filled": "\ue132",
"videocam-filled": "\ue8af",
"personadd": "\ue102",
"upload": "\ue402",
"upload-filled": "\ue8b1",
"starhalf": "\ue463",
"star-filled": "\ue438",
"star": "\ue408",
"trash": "\ue401",
"phone-filled": "\ue230",
"compose": "\ue400",
"videocam": "\ue300",
"trash-filled": "\ue8dc",
"download": "\ue403",
"chatbubble-filled": "\ue232",
"chatbubble": "\ue202",
"cloud-download": "\ue8e4",
"cloud-upload-filled": "\ue8e5",
"cloud-upload": "\ue8e6",
"cloud-download-filled": "\ue8e9",
"headphones":"\ue8bf",
"shop":"\ue609"
"shop":"\ue609"
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,24 @@
## 1.2.42021-08-20
- 优化 close-all 方法
## 1.2.32021-08-20
- 新增 close-all 方法,关闭所有已打开的组件
## 1.2.22021-08-17
- 新增 resize() 方法在非微信小程序、h5、app-vue端出现不能滑动的问题的时候重置组件
- 修复 app 端偶尔出现类似 Page[x][-x,xx;-x,xx,x,x-x] 的问题
- 优化 微信小程序、h5、app-vue 滑动逻辑,避免出现动态新增组件后不能滑动的问题
## 1.2.12021-07-30
- 组件兼容 vue3如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
- 修复 跨页面修改组件数据 ,导致不能滑动的问题
## 1.1.102021-06-17
- 修复 按钮点击执行两次的bug
## 1.1.92021-05-12
- 新增 项目示例地址
## 1.1.82021-03-26
- 修复 微信小程序 nv_navigator is not defined 报错的bug
## 1.1.72021-02-05
- 调整为uni_modules目录规范
- 新增 左侧滑动
- 新增 插槽使用方式
- 新增 threshold 属性,可以控制滑动缺省值
- 优化 长列表滚动性能
- 修复 滚动页面时触发组件滑动的Bug

View File

@@ -0,0 +1,300 @@
// #ifdef APP-NVUE
const BindingX = uni.requireNativePlugin('bindingx');
const dom = uni.requireNativePlugin('dom');
const animation = uni.requireNativePlugin('animation');
export default {
data() {
return {}
},
watch: {
show(newVal) {
if (this.autoClose) return
if (this.stop) return
this.stop = true
if (newVal) {
this.open(newVal)
} else {
this.close()
}
},
leftOptions() {
this.getSelectorQuery()
this.init()
},
rightOptions(newVal) {
this.init()
}
},
created() {
this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) {
this.swipeaction.children.push(this)
}
},
mounted() {
this.box = this.getEl(this.$refs['selector-box--hock'])
this.selector = this.getEl(this.$refs['selector-content--hock']);
this.leftButton = this.getEl(this.$refs['selector-left-button--hock']);
this.rightButton = this.getEl(this.$refs['selector-right-button--hock']);
this.init()
},
// beforeDestroy() {
// this.swipeaction.children.forEach((item, index) => {
// if (item === this) {
// this.swipeaction.children.splice(index, 1)
// }
// })
// },
methods: {
init() {
this.$nextTick(() => {
this.x = 0
this.button = {
show: false
}
setTimeout(() => {
this.getSelectorQuery()
}, 200)
})
},
onClick(index, item, position) {
this.$emit('click', {
content: item,
index,
position
})
},
touchstart(e) {
// 每次只触发一次,避免多次监听造成闪烁
if (this.stop) return
this.stop = true
if (this.autoClose) {
this.swipeaction.closeOther(this)
}
const leftWidth = this.button.left.width
const rightWidth = this.button.right.width
let expression = this.range(this.x, -rightWidth, leftWidth)
let leftExpression = this.range(this.x - leftWidth, -leftWidth, 0)
let rightExpression = this.range(this.x + rightWidth, 0, rightWidth)
this.eventpan = BindingX.bind({
anchor: this.box,
eventType: 'pan',
props: [{
element: this.selector,
property: 'transform.translateX',
expression
}, {
element: this.leftButton,
property: 'transform.translateX',
expression: leftExpression
}, {
element: this.rightButton,
property: 'transform.translateX',
expression: rightExpression
}, ]
}, (e) => {
// nope
if (e.state === 'end') {
this.x = e.deltaX + this.x;
this.isclick = true
this.bindTiming(e.deltaX)
}
});
},
touchend(e) {
if (this.isopen !== 'none' && !this.isclick) {
this.open('none')
}
},
bindTiming(x) {
const left = this.x
const leftWidth = this.button.left.width
const rightWidth = this.button.right.width
const threshold = this.threshold
if (!this.isopen || this.isopen === 'none') {
if (left > threshold) {
this.open('left')
} else if (left < -threshold) {
this.open('right')
} else {
this.open('none')
}
} else {
if ((x > -leftWidth && x < 0) || x > rightWidth) {
if ((x > -threshold && x < 0) || (x - rightWidth > threshold)) {
this.open('left')
} else {
this.open('none')
}
} else {
if ((x < threshold && x > 0) || (x + leftWidth < -threshold)) {
this.open('right')
} else {
this.open('none')
}
}
}
},
/**
* 移动范围
* @param {Object} num
* @param {Object} mix
* @param {Object} max
*/
range(num, mix, max) {
return `min(max(x+${num}, ${mix}), ${max})`
},
/**
* 开启swipe
*/
open(type) {
this.animation(type)
},
/**
* 关闭swipe
*/
close() {
this.animation('none')
},
/**
* 开启关闭动画
* @param {Object} type
*/
animation(type) {
const time = 300
const leftWidth = this.button.left.width
const rightWidth = this.button.right.width
if (this.eventpan && this.eventpan.token) {
BindingX.unbind({
token: this.eventpan.token,
eventType: 'pan'
})
}
switch (type) {
case 'left':
Promise.all([
this.move(this.selector, leftWidth),
this.move(this.leftButton, 0),
this.move(this.rightButton, rightWidth * 2)
]).then(() => {
this.setEmit(leftWidth, type)
})
break
case 'right':
Promise.all([
this.move(this.selector, -rightWidth),
this.move(this.leftButton, -leftWidth * 2),
this.move(this.rightButton, 0)
]).then(() => {
this.setEmit(-rightWidth, type)
})
break
default:
Promise.all([
this.move(this.selector, 0),
this.move(this.leftButton, -leftWidth),
this.move(this.rightButton, rightWidth)
]).then(() => {
this.setEmit(0, type)
})
}
},
setEmit(x, type) {
const leftWidth = this.button.left.width
const rightWidth = this.button.right.width
this.isopen = this.isopen || 'none'
this.stop = false
this.isclick = false
// 只有状态不一致才会返回结果
if (this.isopen !== type && this.x !== x) {
if (type === 'left' && leftWidth > 0) {
this.$emit('change', 'left')
}
if (type === 'right' && rightWidth > 0) {
this.$emit('change', 'right')
}
if (type === 'none') {
this.$emit('change', 'none')
}
}
this.x = x
this.isopen = type
},
move(ref, value) {
return new Promise((resolve, reject) => {
animation.transition(ref, {
styles: {
transform: `translateX(${value})`,
},
duration: 150, //ms
timingFunction: 'linear',
needLayout: false,
delay: 0 //ms
}, function(res) {
resolve(res)
})
})
},
/**
* 获取ref
* @param {Object} el
*/
getEl(el) {
return el.ref
},
/**
* 获取节点信息
*/
getSelectorQuery() {
Promise.all([
this.getDom('left'),
this.getDom('right'),
]).then((data) => {
let show = 'none'
if (this.autoClose) {
show = 'none'
} else {
show = this.show
}
if (show === 'none') {
// this.close()
} else {
this.open(show)
}
})
},
getDom(str) {
return new Promise((resolve, reject) => {
dom.getComponentRect(this.$refs[`selector-${str}-button--hock`], (data) => {
if (data) {
this.button[str] = data.size
resolve(data)
} else {
reject()
}
})
})
}
}
}
// #endif
// #ifndef APP-NVUE
export default {}
// #endif

View File

@@ -0,0 +1,12 @@
export function isPC() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
var flag = true;
for (let v = 0; v < Agents.length - 1; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}

View File

@@ -0,0 +1,193 @@
export default {
data() {
return {
x: 0,
transition: false,
width: 0,
viewWidth: 0,
swipeShow: 0
}
},
watch: {
show(newVal) {
if (this.autoClose) return
if (newVal && newVal !== 'none' ) {
this.transition = true
this.open(newVal)
} else {
this.close()
}
}
},
created() {
this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) {
this.swipeaction.children.push(this)
}
},
mounted() {
this.isopen = false
setTimeout(() => {
this.getQuerySelect()
}, 50)
},
methods: {
appTouchStart(e) {
const {
clientX
} = e.changedTouches[0]
this.clientX = clientX
this.timestamp = new Date().getTime()
},
appTouchEnd(e, index, item, position) {
const {
clientX
} = e.changedTouches[0]
// fixed by xxxx 模拟点击事件,解决 ios 13 点击区域错位的问题
let diff = Math.abs(this.clientX - clientX)
let time = (new Date().getTime()) - this.timestamp
if (diff < 40 && time < 300) {
this.$emit('click', {
content: item,
index,
position
})
}
},
/**
* 移动触发
* @param {Object} e
*/
onChange(e) {
this.moveX = e.detail.x
this.isclose = false
},
touchstart(e) {
this.transition = false
this.isclose = true
this.autoClose && this.swipeaction.closeOther(this)
},
touchmove(e) {},
touchend(e) {
// 0的位置什么都不执行
if (this.isclose && this.isopen === 'none') return
if (this.isclose && this.isopen !== 'none') {
this.transition = true
this.close()
} else {
this.move(this.moveX + this.leftWidth)
}
},
/**
* 移动
* @param {Object} moveX
*/
move(moveX) {
// 打开关闭的处理逻辑不太一样
this.transition = true
// 未打开状态
if (!this.isopen || this.isopen === 'none') {
if (moveX > this.threshold) {
this.open('left')
} else if (moveX < -this.threshold) {
this.open('right')
} else {
this.close()
}
} else {
if (moveX < 0 && moveX < this.rightWidth) {
const rightX = this.rightWidth + moveX
if (rightX < this.threshold) {
this.open('right')
} else {
this.close()
}
} else if (moveX > 0 && moveX < this.leftWidth) {
const leftX = this.leftWidth - moveX
if (leftX < this.threshold) {
this.open('left')
} else {
this.close()
}
}
}
},
/**
* 打开
*/
open(type) {
this.x = this.moveX
this.animation(type)
},
/**
* 关闭
*/
close() {
this.x = this.moveX
// TODO 解决 x 值不更新的问题,所以会多触发一次 nextTick ,待优化
this.$nextTick(() => {
this.x = -this.leftWidth
if(this.isopen!=='none'){
this.$emit('change', 'none')
}
this.isopen = 'none'
})
},
/**
* 执行结束动画
* @param {Object} type
*/
animation(type) {
this.$nextTick(() => {
if (type === 'left') {
this.x = 0
} else {
this.x = -this.rightWidth - this.leftWidth
}
if(this.isopen!==type){
this.$emit('change', type)
}
this.isopen = type
})
},
getSlide(x) {},
getQuerySelect() {
const query = uni.createSelectorQuery().in(this);
query.selectAll('.movable-view--hock').boundingClientRect(data => {
this.leftWidth = data[1].width
this.rightWidth = data[2].width
this.width = data[0].width
this.viewWidth = this.width + this.rightWidth + this.leftWidth
if (this.leftWidth === 0) {
// TODO 疑似bug ,初始化的时候如果x 是0会导致移动位置错误所以让元素超出一点
this.x = -0.1
} else {
this.x = -this.leftWidth
}
this.moveX = this.x
this.$nextTick(() => {
this.swipeShow = 1
})
if (!this.buttonWidth) {
this.disabledView = true
}
if (this.autoClose) return
if (this.show !== 'none') {
this.transition = true
this.open(this.shows)
}
}).exec();
}
}
}

View File

@@ -0,0 +1,258 @@
// #ifndef APP-PLUS|| MP-WEIXIN || H5
const MIN_DISTANCE = 10;
export default {
data() {
// TODO 随机生生元素ID解决百度小程序获取同一个元素位置信息的bug
const elClass = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`
return {
uniShow: false,
left: 0,
buttonShow: 'none',
ani: false,
moveLeft:'',
elClass
}
},
watch: {
show(newVal) {
if (this.autoClose) return
this.openState(newVal)
},
left(){
this.moveLeft = `translateX(${this.left}px)`
},
buttonShow(newVal){
if (this.autoClose) return
this.openState(newVal)
},
leftOptions() {
this.init()
},
rightOptions() {
this.init()
}
},
mounted() {
this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) {
this.swipeaction.children.push(this)
}
this.init()
},
methods: {
init(){
clearTimeout(this.timer)
this.timer = setTimeout(() => {
this.getSelectorQuery()
}, 100)
// 移动距离
this.left = 0
this.x = 0
},
closeSwipe(e) {
if (!this.autoClose) return
this.swipeaction.closeOther(this)
},
appTouchStart(e) {
const {
clientX
} = e.changedTouches[0]
this.clientX = clientX
this.timestamp = new Date().getTime()
},
appTouchEnd(e, index, item, position) {
const {
clientX
} = e.changedTouches[0]
// fixed by xxxx 模拟点击事件,解决 ios 13 点击区域错位的问题
let diff = Math.abs(this.clientX - clientX)
let time = (new Date().getTime()) - this.timestamp
if (diff < 40 && time < 300) {
this.$emit('click', {
content: item,
index,
position
})
}
},
touchstart(e) {
if (this.disabled) return
this.ani = false
this.x = this.left || 0
this.stopTouchStart(e)
this.autoClose && this.closeSwipe()
},
touchmove(e) {
if (this.disabled) return
// 是否可以滑动页面
this.stopTouchMove(e);
if (this.direction !== 'horizontal') {
return;
}
this.move(this.x + this.deltaX)
return false
},
touchend() {
if (this.disabled) return
this.moveDirection(this.left)
},
/**
* 设置移动距离
* @param {Object} value
*/
move(value) {
value = value || 0
const leftWidth = this.leftWidth
const rightWidth = this.rightWidth
// 获取可滑动范围
this.left = this.range(value, -rightWidth, leftWidth);
},
/**
* 获取范围
* @param {Object} num
* @param {Object} min
* @param {Object} max
*/
range(num, min, max) {
return Math.min(Math.max(num, min), max);
},
/**
* 移动方向判断
* @param {Object} left
* @param {Object} value
*/
moveDirection(left) {
const threshold = this.threshold
const isopen = this.isopen || 'none'
const leftWidth = this.leftWidth
const rightWidth = this.rightWidth
if (this.deltaX === 0) {
this.openState('none')
return
}
if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth > 0 && rightWidth +
left < threshold)) {
// right
this.openState('right')
} else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth > 0 &&
leftWidth - left < threshold)) {
// left
this.openState('left')
} else {
// default
this.openState('none')
}
},
/**
* 开启状态
* @param {Boolean} type
*/
openState(type) {
const leftWidth = this.leftWidth
const rightWidth = this.rightWidth
let left = ''
this.isopen = this.isopen ? this.isopen : 'none'
switch (type) {
case "left":
left = leftWidth
break
case "right":
left = -rightWidth
break
default:
left = 0
}
if (this.isopen !== type) {
this.throttle = true
this.$emit('change', type)
}
this.isopen = type
// 添加动画类
this.ani = true
this.$nextTick(() => {
this.move(left)
})
// 设置最终移动位置,理论上只要进入到这个函数,肯定是要打开的
},
close() {
this.openState('none')
},
getDirection(x, y) {
if (x > y && x > MIN_DISTANCE) {
return 'horizontal';
}
if (y > x && y > MIN_DISTANCE) {
return 'vertical';
}
return '';
},
/**
* 重置滑动状态
* @param {Object} event
*/
resetTouchStatus() {
this.direction = '';
this.deltaX = 0;
this.deltaY = 0;
this.offsetX = 0;
this.offsetY = 0;
},
/**
* 设置滑动开始位置
* @param {Object} event
*/
stopTouchStart(event) {
this.resetTouchStatus();
const touch = event.touches[0];
this.startX = touch.clientX;
this.startY = touch.clientY;
},
/**
* 滑动中,是否禁止打开
* @param {Object} event
*/
stopTouchMove(event) {
const touch = event.touches[0];
this.deltaX = touch.clientX - this.startX;
this.deltaY = touch.clientY - this.startY;
this.offsetX = Math.abs(this.deltaX);
this.offsetY = Math.abs(this.deltaY);
this.direction = this.direction || this.getDirection(this.offsetX, this.offsetY);
},
getSelectorQuery() {
const views = uni.createSelectorQuery().in(this)
views
.selectAll('.'+this.elClass)
.boundingClientRect(data => {
if(data.length === 0) return
let show = 'none'
if (this.autoClose) {
show = 'none'
} else {
show = this.show
}
this.leftWidth = data[0].width || 0
this.rightWidth = data[1].width || 0
this.buttonShow = show
})
.exec()
}
}
}
// #endif
// #ifdef APP-PLUS|| MP-WEIXIN || H5
export default { }
// #endif

View File

@@ -0,0 +1,81 @@
// #ifdef APP-VUE|| MP-WEIXIN || H5
import { isPC } from "./isPC"
export default {
data() {
return {
is_show:'none'
}
},
watch: {
show(newVal){
this.is_show = this.show
}
},
created() {
this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) {
this.swipeaction.children.push(this)
}
},
mounted(){
this.is_show = this.show
},
methods: {
// wxs 中调用
closeSwipe(e) {
if (!this.autoClose) return
this.swipeaction.closeOther(this)
},
change(e) {
this.$emit('change', e.open)
if (this.is_show !== e.open) {
this.is_show = e.open
}
},
appTouchStart(e) {
// #ifdef H5
if(isPC()) return
// #endif
const {
clientX
} = e.changedTouches[0]
this.clientX = clientX
this.timestamp = new Date().getTime()
},
appTouchEnd(e, index, item, position) {
// #ifdef H5
if(isPC()) return
// #endif
const {
clientX
} = e.changedTouches[0]
// fixed by xxxx 模拟点击事件,解决 ios 13 点击区域错位的问题
let diff = Math.abs(this.clientX - clientX)
let time = (new Date().getTime()) - this.timestamp
if (diff < 40 && time < 300) {
this.$emit('click', {
content: item,
index,
position
})
}
},
onClickForPC(index, item, position) {
// #ifdef H5
if(!isPC()) return
this.$emit('click', {
content: item,
index,
position
})
// #endif
}
}
}
// #endif
// #ifndef APP-VUE|| MP-WEIXIN || H5
export default {}
// #endif

View File

@@ -0,0 +1,265 @@
const MIN_DISTANCE = 10;
export default {
showWatch(newVal, oldVal, ownerInstance, instance,self) {
let state = self.state
this.getDom(instance, ownerInstance,self)
if (newVal && newVal !== 'none') {
this.openState(newVal, instance, ownerInstance,self)
return
}
if (state.left) {
this.openState('none', instance, ownerInstance,self)
}
this.resetTouchStatus(instance,self)
},
/**
* 开始触摸操作
* @param {Object} e
* @param {Object} ins
*/
touchstart(e, ownerInstance, self) {
let instance = e.instance;
let disabled = instance.getDataset().disabled
let state = self.state;
this.getDom(instance, ownerInstance, self)
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
disabled = this.getDisabledType(disabled)
if (disabled) return
// 开始触摸时移除动画类
instance.requestAnimationFrame(function() {
instance.removeClass('ani');
ownerInstance.callMethod('closeSwipe');
})
// 记录上次的位置
state.x = state.left || 0
// 计算滑动开始位置
this.stopTouchStart(e, ownerInstance, self)
},
/**
* 开始滑动操作
* @param {Object} e
* @param {Object} ownerInstance
*/
touchmove(e, ownerInstance, self) {
let instance = e.instance;
let disabled = instance.getDataset().disabled
let state = self.state
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
disabled = this.getDisabledType(disabled)
if (disabled) return
// 是否可以滑动页面
this.stopTouchMove(e, self);
if (state.direction !== 'horizontal') {
return;
}
if (e.preventDefault) {
// 阻止页面滚动
e.preventDefault()
}
let x = state.x + state.deltaX
this.move(x, instance, ownerInstance, self)
},
/**
* 结束触摸操作
* @param {Object} e
* @param {Object} ownerInstance
*/
touchend(e, ownerInstance, self) {
let instance = e.instance;
let disabled = instance.getDataset().disabled
let state = self.state
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
disabled = this.getDisabledType(disabled)
if (disabled) return
// 滑动过程中触摸结束,通过阙值判断是开启还是关闭
// fixed by mehaotian 定时器解决点击按钮touchend 触发比 click 事件时机早的问题 ,主要是 ios13
this.moveDirection(state.left, instance, ownerInstance, self)
},
/**
* 设置移动距离
* @param {Object} value
* @param {Object} instance
* @param {Object} ownerInstance
*/
move(value, instance, ownerInstance, self) {
value = value || 0
let state = self.state
let leftWidth = state.leftWidth
let rightWidth = state.rightWidth
// 获取可滑动范围
state.left = this.range(value, -rightWidth, leftWidth);
instance.requestAnimationFrame(function() {
instance.setStyle({
transform: 'translateX(' + state.left + 'px)',
'-webkit-transform': 'translateX(' + state.left + 'px)'
})
})
},
/**
* 获取元素信息
* @param {Object} instance
* @param {Object} ownerInstance
*/
getDom(instance, ownerInstance, self) {
let state = self.state
var leftDom = ownerInstance.$el.querySelector('.button-group--left')
var rightDom = ownerInstance.$el.querySelector('.button-group--right')
state.leftWidth = leftDom.offsetWidth || 0
state.rightWidth = rightDom.offsetWidth || 0
state.threshold = instance.getDataset().threshold
},
getDisabledType(value) {
return (typeof(value) === 'string' ? JSON.parse(value) : value) || false;
},
/**
* 获取范围
* @param {Object} num
* @param {Object} min
* @param {Object} max
*/
range(num, min, max) {
return Math.min(Math.max(num, min), max);
},
/**
* 移动方向判断
* @param {Object} left
* @param {Object} value
* @param {Object} ownerInstance
* @param {Object} ins
*/
moveDirection(left, ins, ownerInstance, self) {
var state = self.state
var threshold = state.threshold
var position = state.position
var isopen = state.isopen || 'none'
var leftWidth = state.leftWidth
var rightWidth = state.rightWidth
if (state.deltaX === 0) {
this.openState('none', ins, ownerInstance, self)
return
}
if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth > 0 &&
rightWidth +
left < threshold)) {
// right
this.openState('right', ins, ownerInstance, self)
} else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth > 0 &&
leftWidth - left < threshold)) {
// left
this.openState('left', ins, ownerInstance, self)
} else {
// default
this.openState('none', ins, ownerInstance, self)
}
},
/**
* 开启状态
* @param {Boolean} type
* @param {Object} ins
* @param {Object} ownerInstance
*/
openState(type, ins, ownerInstance, self) {
let state = self.state
let leftWidth = state.leftWidth
let rightWidth = state.rightWidth
let left = ''
state.isopen = state.isopen ? state.isopen : 'none'
switch (type) {
case "left":
left = leftWidth
break
case "right":
left = -rightWidth
break
default:
left = 0
}
// && !state.throttle
if (state.isopen !== type) {
state.throttle = true
ownerInstance.callMethod('change', {
open: type
})
}
state.isopen = type
// 添加动画类
ins.requestAnimationFrame(()=> {
ins.addClass('ani');
this.move(left, ins, ownerInstance, self)
})
},
getDirection(x, y) {
if (x > y && x > MIN_DISTANCE) {
return 'horizontal';
}
if (y > x && y > MIN_DISTANCE) {
return 'vertical';
}
return '';
},
/**
* 重置滑动状态
* @param {Object} event
*/
resetTouchStatus(instance, self) {
let state = self.state;
state.direction = '';
state.deltaX = 0;
state.deltaY = 0;
state.offsetX = 0;
state.offsetY = 0;
},
/**
* 设置滑动开始位置
* @param {Object} event
*/
stopTouchStart(event, ownerInstance, self) {
let instance = event.instance;
let state = self.state
this.resetTouchStatus(instance, self);
var touch = event.touches[0];
state.startX = touch.clientX;
state.startY = touch.clientY;
},
/**
* 滑动中,是否禁止打开
* @param {Object} event
*/
stopTouchMove(event, self) {
let instance = event.instance;
let state = self.state;
let touch = event.touches[0];
state.deltaX = touch.clientX - state.startX;
state.deltaY = touch.clientY - state.startY;
state.offsetY = Math.abs(state.deltaY);
state.offsetX = Math.abs(state.deltaX);
state.direction = state.direction || this.getDirection(state.offsetX, state.offsetY);
}
}

View File

@@ -0,0 +1,348 @@
<template>
<!-- 在微信小程序 app vue端 h5 使用wxs 实现-->
<!-- #ifdef APP-VUE || MP-WEIXIN || H5 -->
<view class="uni-swipe">
<!-- #ifdef MP-WEIXIN || VUE3 -->
<view class="uni-swipe_box" :change:prop="wxsswipe.showWatch"
:prop="is_show" :data-threshold="threshold" :data-disabled="disabled" @touchstart="wxsswipe.touchstart" @touchmove="wxsswipe.touchmove" @touchend="wxsswipe.touchend">
<!-- #endif -->
<!-- #ifndef MP-WEIXIN || VUE3 -->
<view class="uni-swipe_box" :change:prop="renderswipe.showWatch"
:prop="is_show" :data-threshold="threshold" :data-disabled="disabled+''" @touchstart="renderswipe.touchstart" @touchmove="renderswipe.touchmove" @touchend="renderswipe.touchend">
<!-- #endif -->
<!-- 在微信小程序 app vue端 h5 使用wxs 实现-->
<view class="uni-swipe_button-group button-group--left">
<slot name="left">
<view v-for="(item,index) in leftOptions" :key="index" :style="{
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
}" class="uni-swipe_button button-hock" @touchstart="appTouchStart"
@touchend="appTouchEnd($event,index,item,'left')" @click.stop="onClickForPC(index,item,'left')">
<text class="uni-swipe_button-text"
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text>
</view>
</slot>
</view>
<view class="uni-swipe_text--center">
<slot></slot>
</view>
<view class="uni-swipe_button-group button-group--right">
<slot name="right">
<view v-for="(item,index) in rightOptions" :key="index" :style="{
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
}" class="uni-swipe_button button-hock" @touchstart="appTouchStart"
@touchend="appTouchEnd($event,index,item,'right')"
@click.stop="onClickForPC(index,item,'right')"><text class="uni-swipe_button-text"
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text>
</view>
</slot>
</view>
</view>
</view>
<!-- #endif -->
<!-- app nvue端 使用 bindingx -->
<!-- #ifdef APP-NVUE -->
<view ref="selector-box--hock" class="uni-swipe" @horizontalpan="touchstart" @touchend="touchend">
<view ref='selector-left-button--hock' class="uni-swipe_button-group button-group--left">
<slot name="left">
<view v-for="(item,index) in leftOptions" :data-button="btn" :key="index" :style="{
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
}" class="uni-swipe_button button-hock" @click.stop="onClick(index,item,'left')"><text
class="uni-swipe_button-text"
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text>
</view>
</slot>
</view>
<view ref='selector-right-button--hock' class="uni-swipe_button-group button-group--right">
<slot name="right">
<view v-for="(item,index) in rightOptions" :data-button="btn" :key="index" :style="{
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
}" class="uni-swipe_button button-hock" @click.stop="onClick(index,item,'right')"><text
class="uni-swipe_button-text"
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text>
</view>
</slot>
</view>
<view ref='selector-content--hock' class="uni-swipe_box">
<slot></slot>
</view>
</view>
<!-- #endif -->
<!-- 其他平台使用 js 长列表性能可能会有影响-->
<!-- #ifdef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || MP-QQ -->
<view class="uni-swipe">
<view class="uni-swipe_box" @touchstart="touchstart" @touchmove="touchmove" @touchend="touchend"
:style="{transform:moveLeft}" :class="{ani:ani}">
<view class="uni-swipe_button-group button-group--left" :class="[elClass]">
<slot name="left">
<view v-for="(item,index) in leftOptions" :data-button="btn" :key="index" :style="{
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
}" class="uni-swipe_button button-hock" @touchstart="appTouchStart"
@touchend="appTouchEnd($event,index,item,'left')"><text class="uni-swipe_button-text"
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text>
</view>
</slot>
</view>
<slot></slot>
<view class="uni-swipe_button-group button-group--right" :class="[elClass]">
<slot name="right">
<view v-for="(item,index) in rightOptions" :data-button="btn" :key="index" :style="{
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
}" @touchstart="appTouchStart" @touchend="appTouchEnd($event,index,item,'right')"
class="uni-swipe_button button-hock"><text class="uni-swipe_button-text"
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text>
</view>
</slot>
</view>
</view>
</view>
<!-- #endif -->
</template>
<script src="./wx.wxs" module="wxsswipe" lang="wxs"></script>
<script module="renderswipe" lang="renderjs">
import render from './render.js'
export default {
mounted(e,ins,owner) {
this.state = {}
},
methods:{
showWatch(newVal, oldVal, ownerInstance, instance){
render.showWatch(newVal, oldVal, ownerInstance, instance,this)
},
touchstart(e,ownerInstance){
render.touchstart(e,ownerInstance,this)
},
touchmove(e, ownerInstance){
render.touchmove(e,ownerInstance,this)
},
touchend(e,ownerInstance){
render.touchend(e,ownerInstance,this)
}
}
}
</script>
<script>
import mpwxs from './mpwxs'
import bindingx from './bindingx.js'
import mpother from './mpother'
/**
* SwipeActionItem 滑动操作子组件
* @description 通过滑动触发选项的容器
* @tutorial https://ext.dcloud.net.cn/plugin?id=181
* @property {Boolean} show = [left|rightnone] 开启关闭组件auto-close = false 时生效
* @property {Boolean} disabled = [true|false] 是否禁止滑动
* @property {Boolean} autoClose = [true|false] 滑动打开当前组件,是否关闭其他组件
* @property {Number} threshold 滑动缺省值
* @property {Array} leftOptions 左侧选项内容及样式
* @property {Array} rgihtOptions 右侧选项内容及样式
* @event {Function} click 点击选项按钮时触发事件e = {content,index} content点击内容、index下标)
* @event {Function} change 组件打开或关闭时触发left\right\none
*/
export default {
mixins: [mpwxs,bindingx,mpother],
emits:['click','change'],
props: {
// 控制开关
show: {
type: String,
default: 'none'
},
// 禁用
disabled: {
type: Boolean,
default: false
},
// 是否自动关闭
autoClose: {
type: Boolean,
default: true
},
// 滑动缺省距离
threshold: {
type: Number,
default: 20
},
// 左侧按钮内容
leftOptions: {
type: Array,
default () {
return []
}
},
// 右侧按钮内容
rightOptions: {
type: Array,
default () {
return []
}
}
},
// #ifndef VUE3
// TODO vue2
destroyed() {
if (this.__isUnmounted) return
this.uninstall()
},
// #endif
// #ifdef VUE3
// TODO vue3
unmounted() {
this.__isUnmounted = true
this.uninstall()
},
// #endif
methods: {
uninstall() {
if (this.swipeaction) {
this.swipeaction.children.forEach((item, index) => {
if (item === this) {
this.swipeaction.children.splice(index, 1)
}
})
}
},
/**
* 获取父元素实例
*/
getSwipeAction(name = 'uniSwipeAction') {
let parent = this.$parent;
let parentName = parent.$options.name;
while (parentName !== name) {
parent = parent.$parent;
if (!parent) return false;
parentName = parent.$options.name;
}
return parent;
}
}
}
</script>
<style lang="scss" scoped>
.uni-swipe {
position: relative;
/* #ifndef APP-NVUE */
overflow: hidden;
/* #endif */
}
.uni-swipe_box {
/* #ifndef APP-NVUE */
display: flex;
flex-shrink: 0;
// touch-action: none;
/* #endif */
position: relative;
}
.uni-swipe_content {
// border: 1px red solid;
}
.uni-swipe_text--center {
width: 100%;
/* #ifndef APP-NVUE */
cursor: grab;
/* #endif */
}
.uni-swipe_button-group {
/* #ifndef APP-NVUE */
box-sizing: border-box;
display: flex;
/* #endif */
flex-direction: row;
position: absolute;
top: 0;
bottom: 0;
/* #ifdef H5 */
cursor: pointer;
/* #endif */
}
.button-group--left {
left: 0;
transform: translateX(-100%)
}
.button-group--right {
right: 0;
transform: translateX(100%)
}
.uni-swipe_button {
/* #ifdef APP-NVUE */
flex: 1;
/* #endif */
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
align-items: center;
padding: 0 20px;
}
.uni-swipe_button-text {
/* #ifndef APP-NVUE */
flex-shrink: 0;
/* #endif */
font-size: 14px;
}
.ani {
transition-property: transform;
transition-duration: 0.3s;
transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
}
/* #ifdef MP-ALIPAY */
.movable-area {
/* width: 100%; */
height: 45px;
}
.movable-view {
display: flex;
/* justify-content: center; */
position: relative;
flex: 1;
height: 45px;
z-index: 2;
}
.movable-view-button {
display: flex;
flex-shrink: 0;
flex-direction: row;
height: 100%;
background: #C0C0C0;
}
/* .transition {
transition: all 0.3s;
} */
.movable-view-box {
flex-shrink: 0;
height: 100%;
background-color: #fff;
}
/* #endif */
</style>

View File

@@ -0,0 +1,341 @@
var MIN_DISTANCE = 10;
/**
* 判断当前是否为H5、app-vue
*/
var IS_HTML5 = false
if (typeof window === 'object') IS_HTML5 = true
/**
* 监听页面内值的变化,主要用于动态开关swipe-action
* @param {Object} newValue
* @param {Object} oldValue
* @param {Object} ownerInstance
* @param {Object} instance
*/
function showWatch(newVal, oldVal, ownerInstance, instance) {
var state = instance.getState()
getDom(instance, ownerInstance)
if (newVal && newVal !== 'none') {
openState(newVal, instance, ownerInstance)
return
}
if (state.left) {
openState('none', instance, ownerInstance)
}
resetTouchStatus(instance)
}
/**
* 开始触摸操作
* @param {Object} e
* @param {Object} ins
*/
function touchstart(e, ownerInstance) {
var instance = e.instance;
var disabled = instance.getDataset().disabled
var state = instance.getState();
getDom(instance, ownerInstance)
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
if (disabled) return
// 开始触摸时移除动画类
instance.requestAnimationFrame(function() {
instance.removeClass('ani');
ownerInstance.callMethod('closeSwipe');
})
// 记录上次的位置
state.x = state.left || 0
// 计算滑动开始位置
stopTouchStart(e, ownerInstance)
}
/**
* 开始滑动操作
* @param {Object} e
* @param {Object} ownerInstance
*/
function touchmove(e, ownerInstance) {
var instance = e.instance;
var disabled = instance.getDataset().disabled
var state = instance.getState()
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
if (disabled) return
// 是否可以滑动页面
stopTouchMove(e);
if (state.direction !== 'horizontal') {
return;
}
if (e.preventDefault) {
// 阻止页面滚动
e.preventDefault()
}
move(state.x + state.deltaX, instance, ownerInstance)
}
/**
* 结束触摸操作
* @param {Object} e
* @param {Object} ownerInstance
*/
function touchend(e, ownerInstance) {
var instance = e.instance;
var disabled = instance.getDataset().disabled
var state = instance.getState()
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
if (disabled) return
// 滑动过程中触摸结束,通过阙值判断是开启还是关闭
// fixed by mehaotian 定时器解决点击按钮touchend 触发比 click 事件时机早的问题 ,主要是 ios13
moveDirection(state.left, instance, ownerInstance)
}
/**
* 设置移动距离
* @param {Object} value
* @param {Object} instance
* @param {Object} ownerInstance
*/
function move(value, instance, ownerInstance) {
value = value || 0
var state = instance.getState()
var leftWidth = state.leftWidth
var rightWidth = state.rightWidth
// 获取可滑动范围
state.left = range(value, -rightWidth, leftWidth);
instance.requestAnimationFrame(function() {
instance.setStyle({
transform: 'translateX(' + state.left + 'px)',
'-webkit-transform': 'translateX(' + state.left + 'px)'
})
})
}
/**
* 获取元素信息
* @param {Object} instance
* @param {Object} ownerInstance
*/
function getDom(instance, ownerInstance) {
var state = instance.getState()
var leftDom = ownerInstance.selectComponent('.button-group--left')
var rightDom = ownerInstance.selectComponent('.button-group--right')
var leftStyles = {
width: 0
}
var rightStyles = {
width: 0
}
leftStyles = leftDom.getBoundingClientRect()
rightStyles = rightDom.getBoundingClientRect()
state.leftWidth = leftStyles.width || 0
state.rightWidth = rightStyles.width || 0
state.threshold = instance.getDataset().threshold
}
/**
* 获取范围
* @param {Object} num
* @param {Object} min
* @param {Object} max
*/
function range(num, min, max) {
return Math.min(Math.max(num, min), max);
}
/**
* 移动方向判断
* @param {Object} left
* @param {Object} value
* @param {Object} ownerInstance
* @param {Object} ins
*/
function moveDirection(left, ins, ownerInstance) {
var state = ins.getState()
var threshold = state.threshold
var position = state.position
var isopen = state.isopen || 'none'
var leftWidth = state.leftWidth
var rightWidth = state.rightWidth
if (state.deltaX === 0) {
openState('none', ins, ownerInstance)
return
}
if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth > 0 &&
rightWidth +
left < threshold)) {
// right
openState('right', ins, ownerInstance)
} else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth > 0 &&
leftWidth - left < threshold)) {
// left
openState('left', ins, ownerInstance)
} else {
// default
openState('none', ins, ownerInstance)
}
}
/**
* 开启状态
* @param {Boolean} type
* @param {Object} ins
* @param {Object} ownerInstance
*/
function openState(type, ins, ownerInstance) {
var state = ins.getState()
var leftWidth = state.leftWidth
var rightWidth = state.rightWidth
var left = ''
state.isopen = state.isopen ? state.isopen : 'none'
switch (type) {
case "left":
left = leftWidth
break
case "right":
left = -rightWidth
break
default:
left = 0
}
// && !state.throttle
if (state.isopen !== type) {
state.throttle = true
ownerInstance.callMethod('change', {
open: type
})
}
state.isopen = type
// 添加动画类
ins.requestAnimationFrame(function() {
ins.addClass('ani');
move(left, ins, ownerInstance)
})
// 设置最终移动位置,理论上只要进入到这个函数,肯定是要打开的
}
function getDirection(x, y) {
if (x > y && x > MIN_DISTANCE) {
return 'horizontal';
}
if (y > x && y > MIN_DISTANCE) {
return 'vertical';
}
return '';
}
/**
* 重置滑动状态
* @param {Object} event
*/
function resetTouchStatus(instance) {
var state = instance.getState();
state.direction = '';
state.deltaX = 0;
state.deltaY = 0;
state.offsetX = 0;
state.offsetY = 0;
}
/**
* 设置滑动开始位置
* @param {Object} event
*/
function stopTouchStart(event) {
var instance = event.instance;
var state = instance.getState();
resetTouchStatus(instance);
var touch = event.touches[0];
if (IS_HTML5 && isPC()) {
touch = event;
}
state.startX = touch.clientX;
state.startY = touch.clientY;
}
/**
* 滑动中,是否禁止打开
* @param {Object} event
*/
function stopTouchMove(event) {
var instance = event.instance;
var state = instance.getState();
var touch = event.touches[0];
if (IS_HTML5 && isPC()) {
touch = event;
}
state.deltaX = touch.clientX - state.startX;
state.deltaY = touch.clientY - state.startY;
state.offsetY = Math.abs(state.deltaY);
state.offsetX = Math.abs(state.deltaX);
state.direction = state.direction || getDirection(state.offsetX, state.offsetY);
}
function isPC() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length - 1; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}
var movable = false
function mousedown(e, ins) {
if (!IS_HTML5) return
if (!isPC()) return
touchstart(e, ins)
movable = true
}
function mousemove(e, ins) {
if (!IS_HTML5) return
if (!isPC()) return
if (!movable) return
touchmove(e, ins)
}
function mouseup(e, ins) {
if (!IS_HTML5) return
if (!isPC()) return
touchend(e, ins)
movable = false
}
function mouseleave(e, ins) {
if (!IS_HTML5) return
if (!isPC()) return
movable = false
}
module.exports = {
showWatch: showWatch,
touchstart: touchstart,
touchmove: touchmove,
touchend: touchend,
mousedown: mousedown,
mousemove: mousemove,
mouseup: mouseup,
mouseleave: mouseleave
}

View File

@@ -0,0 +1,60 @@
<template>
<view>
<slot></slot>
</view>
</template>
<script>
/**
* SwipeAction 滑动操作
* @description 通过滑动触发选项的容器
* @tutorial https://ext.dcloud.net.cn/plugin?id=181
*/
export default {
name:"uniSwipeAction",
data() {
return {};
},
created() {
this.children = [];
},
methods: {
// 公开给用户使用,重制组件样式
resize(){
// wxs 会自己计算组件大小,所以无需执行下面代码
// #ifndef APP-VUE || H5 || MP-WEIXIN
this.children.forEach(vm=>{
vm.init()
})
// #endif
},
// 公开给用户使用,关闭全部 已经打开的组件
closeAll(){
this.children.forEach(vm=>{
// #ifdef APP-VUE || H5 || MP-WEIXIN
vm.is_show = 'none'
// #endif
// #ifndef APP-VUE || H5 || MP-WEIXIN
vm.close()
// #endif
})
},
closeOther(vm) {
if (this.openItem && this.openItem !== vm) {
// #ifdef APP-VUE || H5 || MP-WEIXIN
this.openItem.is_show = 'none'
// #endif
// #ifndef APP-VUE || H5 || MP-WEIXIN
this.openItem.close()
// #endif
}
// 记录上一个打开的 swipe-action-item ,用于 auto-close
this.openItem = vm
}
}
};
</script>
<style></style>

View File

@@ -0,0 +1,87 @@
{
"id": "uni-swipe-action",
"displayName": "uni-swipe-action 滑动操作",
"version": "1.2.4",
"description": "SwipeAction 滑动操作操作组件",
"keywords": [
"",
"uni-ui",
"uniui",
"滑动删除",
"侧滑删除"
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
"HBuilderX": ""
},
"directories": {
"example": "../../temps/example_temps"
},
"dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
},
"快应用": {
"华为": "y",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "u"
}
}
}
}
}

View File

@@ -0,0 +1,193 @@
## SwipeAction 滑动操作
> **组件名uni-swipe-action**
> 代码块: `uSwipeAction`、`uSwipeActionItem`
通过滑动触发选项的容器
> **注意事项**
> 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。
> - swipeAction的跟手联动是非常考验性能的。为了提高交互体验本组件在 app 端 vue 页面、h5、微信小程序使用了wxs 技术nvue 页面使用 bindingx 技术,可以达到流畅的体验。在其他小程序平台由于底层不支持优化技术,只能使用使用普通 js ,此时性能一般。
> - `uni-swipe-action` 和 `uni-swipe-action-item` 需要同时使用
> - `uni-swipe-action` 不能嵌套在 `swiper` 中使用
> - 长列表不建议使用 autoClose属性会影响组件性能造成卡顿原因是打开之后要通知其他已经打开的组件关闭会导致多个组件重新渲染
> - 事件中传入 `$event` 获取额外参数
> - 向下兼容,需要将 `options` 属性替换成 `right-options`
> - 如使用过程中有任何问题或者您对uni-ui有一些好的建议欢迎加入 uni-ui 交流群871950839
### 安装方式
本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`
如需通过`npm`方式使用`uni-ui`组件,另见文档:[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55)
## 基本用法
在 ``template`` 中的使用
```html
<uni-swipe-action>
<!-- 基础用法 -->
<uni-swipe-action-item :right-options="options" :left-options="options" @click="onClick" @change="change">
<view>SwipeAction 基础使用场景</view>
</uni-swipe-action-item>
<!-- 使用插槽 (请自行给定插槽内容宽度)-->
<uni-swipe-action-item>
<template v-slot:left>
<view><text>置顶</text></view>
</template>
<view>
<text >使用插槽</text>
</view>
<template v-slot:right>
<view><text>删除</text></view>
</template>
</uni-swipe-action-item>
<!-- 混合用法 -->
<uni-swipe-action-item :right-options="options">
<template v-slot:left>
<view><text>置顶</text></view>
</template>
<view><text>混合使用</text></view>
</uni-swipe-action-item>
</uni-swipe-action>
<!-- 禁止滑动 -->
<uni-swipe-action>
<uni-swipe-action-item :disabled="true" :right-options="options">
<view>SwipeAction 基础使用场景</view>
</uni-swipe-action-item>
</uni-swipe-action>
<!-- 按组使用 -->
<uni-swipe-action>
<uni-swipe-action-item :right-options="options" @click="bindClick" @change="swipeChange($event, index)">
<view >item1</view>
</uni-swipe-action-item>
<uni-swipe-action-item :right-options="options" @click="bindClick" @change="swipeChange($event, index)">
<view>item2</view>
</uni-swipe-action-item>
<uni-swipe-action-item :right-options="options" @click="bindClick" @change="swipeChange($event, index)">
<view>item3</view>
</uni-swipe-action-item>
</uni-swipe-action>
```
```javascript
export default {
data(){
return {
options:[
{
text: '取消',
style: {
backgroundColor: '#007aff'
}
}, {
text: '确认',
style: {
backgroundColor: '#dd524d'
}
}
]
}
},
methods:{
onClick(e){
console.log('点击了'+(e.position === 'left' ? '左侧' : '右侧') + e.content.text + '按钮')
},
swipeChange(e,index){
console.log('当前状态:'+ e +',下标:' + index)
}
}
}
```
## API
### SwipeAciton Props
|属性名|类型|可选值|默认值|是否必填|说明|
|:-:|:-:|:-:|:-:|:-:|:-:|
|show|String|left/right/none|none |否|开启关闭组件auto-close = false 时生效|
|threshold|Number|-|20|否|滑动阙值|
|disabled|Boolean|-|false|否|是否禁止滑动|
|autoClose|Boolean|-|true|否|其他组件开启的时候,当前组件是否自动关闭,**注意:长列表使用会有性能问题**|
|left-options|Array/Object |-|-|否|左侧选项内容及样式|
|right-options|Array/Object |-|-|否|右侧选项内容及样式|
#### LeftOptions & RightOptions Options
|参数|类型|是否必填 |说明|
|:-:|:-:|:-:|:-:|
|text|String|是|按钮的文字 |
|style|Object|否|按钮样式{backgroundColor,color,fontSize}backgroundColor默认为#C7C6CDcolor默认为#FFFFFFfontSize默认为14px |
### SwipeAction Events
|事件称名 |说明|返回值|
|:-:|:-:|:-:|
|@click|点击选项按钮时触发事件|e = {content,index} content点击内容、index下标、position (位置信息) |
|@change|组件打开或关闭时触发|left:左侧 right右侧none关闭|
### SwipeAction Methods
方法通过 ref 调用
|方法称名 |说明|
|:-:|:-:|
|resize()|动态添加数据后如不能正常滑动需要主动调用此方法微信小程序、h5、app-vue 不生效|
|close-all()|关闭所有已经打开的组件|
### SwipeAction Slots
|名称|说明|
|:-:|:-:|
|-|默认插槽自定义显示内容|
|default|默认内容插槽|
|left|左侧滑动内容 ,会覆盖 leftOptions 内容|
|right|右侧滑动内容 ,会覆盖 rightOptions 内容|
> **提示**
> - iOS 端由于存在bounce效果滑动体验略差建议禁止bounce效果禁止方式如下
> ```javascript
> {
> "path": "swipe-action/swipe-action",
> "style": {
> "navigationBarTitleText": "SwipeAction 滑动操作",
> "disableScroll":true,
> "app-plus":{
> "bounce":"none"
> }
> }
> }
> ```
### Q&A
1. Q动态加载数据组件滑动失效是怎么回事
- A是因为组件会在加载的时候获取相应的节点信息数据 ,获取需要滑动的距离,所以有时候动态加载数据之后,可能是时机的问题,导致节点信息获取失败 ,那么组件就不能正常滑动。
- A如果是在其他页面通过 vuex 或者uni.$emit 等手段来更新其他页面 uni-swipe-action 数据 ,同样会发生不能滑动的现象,原因是页面隐藏后是不能获取到页面信息的,所以回到 uni-swipe-action 页面后,新增的组件节点信息获取肯定是错误的,所以不能滑动。
- A值的高兴的是在 1.2.2 版本中重构了组件滑动逻辑 在微信小程序、h5、app-vue 中使用了 wxs 优化滑动性能,并且不需要担心动态新增组件导致组件无法滑动的问题,节点信息在滑动时实时获取。
- A因为其他平台无法使用 wxs 所以还是会出现无法滑动的问题怎么处理1.2.2 版本提供了 resize() 方法,无法滑动时调用 resize() 方法重新渲染组件即可,调用方法时要保证节点已经渲染完毕。
2. Q运行到 nvue 下没有样式
- A因为 nvue 下样式默认不能使用复杂的css选择器所以需要在 manifest.json 中配置 "nvueStyleCompiler" 属性
```json
// manifest.json
{
"nvueStyleCompiler" : "uni-app",
}
```
## 组件示例
点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/swipe-action/swipe-action](https://hellouniapp.dcloud.net.cn/pages/extUI/swipe-action/swipe-action)