zmr #6

Merged
zhaomingrui merged 3 commits from zmr into master 2020-07-16 02:11:40 +00:00
9 changed files with 460 additions and 98 deletions

13
common/api/user.js Normal file
View File

@ -0,0 +1,13 @@
export default {
init(vm){
return {
// 首页协议 列子
// documentInfo({document_code}) {
// return vm.$u.post('StartUp/documentInfo', {
// document_code : document_code
// });
// },
}
}
}

16
common/http.api.js Normal file
View File

@ -0,0 +1,16 @@
// 此处第二个参数vm就是我们在页面使用的this你可以通过vm获取vuex等操作更多内容详见uView对拦截器的介绍部分
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
// import shop from "./api/shop"
import user from "./api/user"
const install = (Vue, vm) => {
let userApi = user.init(vm)
// let shopApi = shop.init(vm)
// 将各个定义的接口名称统一放进对象挂载到vm.$u.api(因为vm就是this也即this.$u.api)下
vm.$u.api = {...userApi};
}
export default {
install
}

View File

@ -0,0 +1,64 @@
const install = (Vue, vm) => {
// 此为自定义配置参数,具体参数见上方说明
Vue.prototype.$u.http.setConfig({
baseUrl: 'https://dmmall.sdbairui.com/api',
loadingText: '努力加载中~',
loadingTime: 800
// ......
});
// 请求拦截配置Token等参数
Vue.prototype.$u.http.interceptor.request = (config) => {
// 引用token
// 方式一存放在vuex的token假设使用了uView封装的vuex方式
// 见https://uviewui.com/components/globalVariable.html
// config.header.token = vm.token;
// 方式二如果没有使用uView封装的vuex方法那么需要使用$store.state获取
// config.header.token = vm.$store.state.token;
// 方式三如果token放在了globalData通过getApp().globalData获取
// config.header.token = getApp().globalData.username;
// 方式四如果token放在了Storage本地存储中拦截是每次请求都执行的
// 所以哪怕您重新登录修改了Storage下一次的请求将会是最新值
const token = uni.getStorageSync('token');
// console.log(token);
// config.header.token = token;
config.header.Authorization = 'Bearer' + " " + token;
// config.header.Token = 'xxxxxx';
// 可以对某个url进行特别处理此url参数为this.$u.get(url)中的url值
// if(config.url == '/user/login') config.header.noToken = true;
// 最后需要将config进行return
return config;
// 如果return一个false值则会取消本次请求
// if(config.url == '/user/rest') return false; // 取消某次请求
}
// // 响应拦截,判断状态码是否通过
// Vue.prototype.$u.http.interceptor.response = (res) => {
// if(res.code == 200) {
// // res为服务端返回值可能有coderesult等字段
// // 这里对res.result进行返回将会在this.$u.post(url).then(res => {})的then回调中的res的到
// // 如果配置了originalData为true请留意这里的返回值
// return res.result;
// } else if(res.code == 201) {
// // 假设201为token失效这里跳转登录
// vm.$u.toast('验证失败,请重新登录');
// setTimeout(() => {
// // 此为uView的方法详见路由相关文档
// vm.$u.route('/pages/user/login')
// }, 1500)
// return false;
// } else {
// // 如果返回false则会调用Promise的reject回调
// // 并将进入this.$u.post(url).then().catch(res=>{})的catch回调中res为服务端的返回值
// return false;
// }
// }
}
export default {
install
}

11
main.js
View File

@ -12,3 +12,14 @@ const app = new Vue({
...App ...App
}) })
app.$mount() app.$mount()
// http拦截器将此部分放在new Vue()和app.$mount()之间才能App.vue中正常使用
import httpInterceptor from '@/common/http.interceptor.js'
Vue.use(httpInterceptor, app)
// http接口API集中管理引入部分
import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)
app.$mount()

View File

@ -3,18 +3,7 @@
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue" "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
}, },
"pages": [ "pages": [
{
"path": "pages/release/tosign",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom",
"app-plus": {
"titleNView": false,
"backgroundColor": "#f00",
"animationType": "slide-in-bottom"
}
}
},
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
@ -89,6 +78,18 @@
} }
} }
}, },
{
"path": "pages/release/tosign",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom",
"app-plus": {
"titleNView": false,
"backgroundColor": "#FFFFFF",
"animationType": "slide-in-bottom"
}
}
},
{ {
"path": "pages/user/info", "path": "pages/user/info",
"style": { "style": {

View File

@ -1,113 +1,370 @@
<template> <template>
<view id="release"> <view id="release">
<u-form :model="form" ref="uForm"> <u-form :model="form" ref="uForm">
<u-form-item label="标题" label-position="right"> <u-form-item label="标题" label-position="right">
<u-input v-model="form.name" placeholder="请输入标题" /> <u-input v-model="form.name" placeholder="请输入标题" />
</u-form-item> </u-form-item>
<view class="titles">图片</view> <view class="titles">图片</view>
<u-upload :action="action" del-color="#ececec" upload-text="选择图片" del-bg-color="#fff" :file-list="fileList" ></u-upload> <u-upload :action="action" del-color="#ececec" upload-text="选择图片" del-bg-color="#fff" :file-list="fileList"></u-upload>
<!-- 标签 --> <!-- 标签 -->
<view> <view>
<view class="titles">标签</view> <view class="titles">标签</view>
<view class="form-view" @click="show_add()">+ 新建标签</view> <view class="form-view" @click="show_add()">+ 新建标签</view>
<view class="form-view" v-for="(item,index) in fileListes" :key="index">{{item}}</view> <view class="form-view" v-for="(item,index) in fileListes" :key="index">{{item}}</view>
</view> </view>
<!-- 简介 --> <!-- 简介 -->
<view class="titles">正文</view> <view class="titles">简介</view>
<view class="titles_border">
<textarea placeholder="请输入内容..."></textarea> <textarea placeholder="请输入内容..."></textarea>
<!-- 提交 --> </view>
<u-button class="custom-style" shape="circle" size="default">发表</u-button> <!-- 底部弹框 商品选择 -->
</u-form> <view class="show_two">
<!-- 添加标签的按钮 --> <u-popup v-model="show_two" mode="bottom" :closeable="true">
<u-popup v-model="show" mode="center" border-radius="14" :closeable="true"> <view class="title">
<view class="text"> <text>选择商品</text>
创建属于你的标签吧 </view>
<!-- 商品列表 -->
<view class="listes_shoping" v-for="(item, index) in list" :key="index">
<view>
<u-checkbox-group @change="checkboxGroupChange">
<u-checkbox @change="checkboxChange" shape="circle" active-color="#FF780F" v-model="item.checked" :name="item.id"></u-checkbox>
</u-checkbox-group>
</view>
<view>
<image :src="item.url" mode="widthFix"></image>
</view>
<view class="contentes">{{item.content}}</view>
</view>
<!-- 提交按钮 -->
<view class="u-button" @click="changes()">确定</view>
</u-popup>
<!-- 底部选择商品列表 -->
<view @click="show_two = true">选择商品
<image class="images" src="../../static/image/tosign/bhottom.png"></image>
</view> </view>
<view class="u-inputes"> <!-- 选择后的列表 -->
<u-input v-model="form.name" /> <view class="List_tosign" v-if="List_tosign != ''">
<view>
<image src="../../static/image/tosign/tosigin(5).png" mode="scaleToFill"></image>
</view>
<view>
木糖少女小紫薯西装领连衣裙夏季新款女装夏收腰格子格纹裙子
</view>
<view>
<image src="../../static/image/tosign/delete.png" mode="widthFix"></image>
</view>
</view> </view>
<u-button class="custom-style-button" shape="circle" size="default">确定</u-button> </view>
</u-popup> <!-- 提交 -->
<u-button class="custom-style" shape="circle" size="default">发表</u-button>
</u-form>
<!-- 添加标签的按钮 -->
<u-popup v-model="show" mode="center" border-radius="14">
<view class="text">
创建属于你的标签吧
</view>
<view class="u-inputes">
<u-input v-model="form.name" />
</view>
<u-button class="custom-style-button" shape="circle" size="default">确定</u-button>
</u-popup>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
form: { form: {
name: '', name: '',
intro: '', intro: '',
sex: '' sex: ''
},
// 使
action: 'http://www.example.com/upload',
fileList: [],
fileListes: ["美妆", "博主穿搭", "美妆", "美妆", "美妆", "美妆", "美妆", "博主穿搭"],
show: false,
show_two: false,
filesList: [],
arres_list : [],
checked: false,
list: [{
name: 'apple',
checked: false,
disabled: false,
content: "木糖少女小紫薯西装领连衣裙夏季新款女装装领连衣裙夏季装领连衣裙夏季装领连衣裙夏季夏收腰格子格纹裙子",
url: '../../static/image/tosign/tosigin(5).png',
id : '1'
}, },
// 使 {
action: 'http://www.example.com/upload', name: 'apple2',
fileList: [], checked: false,
fileListes:["美妆","博主穿搭","美妆","美妆","美妆","美妆","美妆","博主穿搭"], disabled: false,
show: false content: "木糖少女小紫薯西装领连衣裙夏季新款女装夏收腰格子格纹裙子",
url: '../../static/image/tosign/tosigin(5).png',
id : '2'
},
{
name: 'appl3e',
checked: false,
disabled: false,
content: "木糖少女小紫薯西装领连衣裙夏季新款女装夏收腰格子格纹裙子",
url: '../../static/image/tosign/tosigin(5).png',
id : '3'
},
],
List_tosign : []
}
},
onLoad(){
//
this.tosign()
},
methods: {
changes() {
let that = this;
that.show_two = false;
console.log(that.arres_list);
//
that.arres_list = [...new Set(that.arres_list)];
console.log(that.arres_list)
},
show_add() {
console.log(this.show)
this.show = !this.show
},
// checkbox
checkboxChange(e) {
console.log(e);
if(e.value == true){
let id = e.name;
this.pushes(id)
} }
}, },
methods:{ pushes(id){
show_add(){ var that = this;
console.log(this.show) console.log(id)
this.show = !this.show if(id == ''){
console.log("为空")
}else{
that.arres_list.push(id);
}
},
// checkboxcheckbox-group
checkboxGroupChange(e) {
console.log(e);
},
tosign(){
console.log("111")
this.$u.api.documentInfo({
document_code: 'privacy'
}).then((res)=>{
console.log(res)
})
try {
const value = uni.getStorageSync('list_tosign');
if (value) {
console.log(value);
}
} catch (e) {
// error
} }
} }
} }
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
#release{ #release {
width: 690rpx; width: 690rpx;
margin: 0 auto; margin: 0 auto;
.form-view{
background:rgba(255,120,15,1); .form-view {
border-radius:6rpx; background: rgba(255, 120, 15, 1);
margin-right: 20rpx; border-radius: 6rpx;
font-size: 24rpx; margin-right: 20rpx;
padding: 8rpx 20rpx; font-size: 24rpx;
display: inline-block; padding: 8rpx 20rpx;
margin-bottom: 28rpx; display: inline-block;
color: #fff; margin-bottom: 28rpx;
color: #fff;
}
.titles {
font-size: 30rpx;
font-weight: 400;
color: rgba(51, 51, 51, 1);
margin: 30rpx 0;
}
textarea {
font-size: 26rpx;
}
.custom-style {
background: rgba(255, 120, 15, 1) !important;
color: #fff !important;
font-size: 36rpx;
}
.custom-style-button {
background: rgba(255, 120, 15, 1) !important;
color: #fff !important;
font-size: 28rpx;
width: 200rpx;
margin-bottom: 23rpx;
line-height: 60rpx;
height: 60rpx;
}
.show_two .title {
width: 100%;
border-bottom: solid 1px #ECECEC;
margin-bottom: 30rpx;
}
.show_two .title>text {
font-size: 30rpx;
padding: 30rpx;
display: block;
}
.listes_shoping {
overflow: hidden;
zoom: 1;
margin-bottom: 30rpx;
height: 160rpx;
position: relative;
}
.listes_shoping>view {
float: left;
}
.listes_shoping>view:nth-child(1) {
width: 36rpx;
height: 36rpx;
margin-top: 62rpx;
margin-left: 30rpx;
}
.listes_shoping>view:nth-child(2) {
width: 180rpx;
height: 160rpx;
margin: 0 31rpx 0 19rpx;
}
.listes_shoping>view:nth-child(2) image {
width: 100%;
}
.listes_shoping>view:nth-child(3) {
width: 425rpx;
margin-top: 43rpx;
overflow: hidden;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.u-button {
background: #FF780F;
width: 690rpx;
height: 98rpx;
line-height: 98rpx;
background: rgba(255, 120, 15, 1);
border-radius: 49px;
font-size: 36rpx;
color: #FFFFFF;
text-align: center;
margin: 0 auto 20rpx;
}
} }
.titles{
font-size:30rpx; .u-mode-center-box {
font-weight:400; padding: 120rpx;
color:rgba(51,51,51,1);
.text {
font-size: 30rpx;
margin-top: 74rpx;
text-align: center;
font-weight: 500;
color: #333;
}
}
.titles_border,
.uni-textarea-compute {
border: 1px #BABABA solid !important;
padding: 10rpx;
border-radius: 10rpx;
}
.u-inputes {
margin: 30rpx 0; margin: 30rpx 0;
border: 1px #ececec solid;
padding-left: 14rpx;
width: 420rpx;
} }
textarea{
font-size: 26rpx; .show_two {
padding: 30rpx 0 70rpx 0;
} }
.custom-style{
background:rgba(255,120,15,1)!important; .show_two>view {
color: #fff!important;
font-size: 36rpx;
}
.custom-style-button{
background:rgba(255,120,15,1)!important;
color: #fff!important;
font-size: 28rpx;
width: 200rpx;
margin-bottom: 23rpx;
line-height: 60rpx;
height: 60rpx;
}
}
.u-mode-center-box{
padding: 120rpx;
.text{
font-size: 30rpx; font-size: 30rpx;
margin-top: 74rpx; font-weight: 400;
text-align: center; color: rgba(51, 51, 51, 1);
font-weight: 500; }
color: #333;
.show_two .images {
width: 22rpx;
height: 12rpx;
float: right;
top: 14rpx;
}
.List_tosign {
overflow: hidden;
zoom: 1;
margin-top: 21rpx;
position: relative;
}
.List_tosign > view{
float: left;
}
.List_tosign> view:nth-child(1) {
width: 180rpx;
height: 160rpx;
margin-bottom: 30rpx;
image{
border-radius: 15rpx;
width: 100%;
height: 100%;
}
}
.List_tosign> view:nth-child(2) {
width: 420rpx;
height: 76rpx;
margin: 43rpx 43rpx 0 21rpx;
}
.List_tosign> view:nth-child(3) {
width: 26rpx;
height: 27rpx;
position: absolute;
top: 0;
right: 0;
bottom: 0;
margin: auto;
image{
width: 100%;
height: 100%;
display: block;
}
} }
}
.u-inputes{
margin: 30rpx 0;
border: 1px #ececec solid;
padding-left: 14rpx;
width: 420rpx;
}
</style> </style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB