添加意见反馈页面

This commit is contained in:
qianlile
2021-08-30 19:26:45 +08:00
parent e50ba21896
commit df355a880b
20 changed files with 751 additions and 12 deletions

View File

@@ -5,7 +5,9 @@
"pages/my/my",
"pages/add4G/index",
"pages/4Gswitch/index",
"pages/deviceDetail/index"
"pages/addWiFi/index",
"pages/deviceDetail/index",
"pages/feedBack/feedBack"
],
"window": {
"backgroundColor": "#F6F6F6",
@@ -52,6 +54,8 @@
"van-tag": "@vant/weapp/tag/index",
"van-button": "@vant/weapp/button/index",
"van-cell": "@vant/weapp/cell/index",
"van-cell-group": "@vant/weapp/cell-group/index"
"van-cell-group": "@vant/weapp/cell-group/index",
"van-radio": "@vant/weapp/radio/index",
"van-radio-group": "@vant/weapp/radio-group/index"
}
}

BIN
wechat/icons/acc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
wechat/icons/delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
wechat/icons/light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

BIN
wechat/icons/phone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
wechat/icons/suggest.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
wechat/icons/yes.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@@ -17,13 +17,10 @@ Page({
*/
onLoad: function (options) {
this.setNavigate();
try {
if (getCurrentPages().length > 1) {
this.getLastPageData();
} catch (error) {
console.log(error);
}
this.isShared(options);
},
checkLogin(){
@@ -85,7 +82,7 @@ Page({
getLastPageData(){
const eventChannel = this.getOpenerEventChannel();
const that = this;
eventChannel.on('getDeviceInfo',async (data)=>{
eventChannel.on('getDeviceInfo',(data)=>{
that.setData({
deviceId:data
})
@@ -95,6 +92,7 @@ Page({
async getDeviceDetail(){
let deviceId = this.data.deviceId;
console.log(deviceId);
const res = await request(`system/device/getDeviceInfoByDeviceId?deviceId=${deviceId}`,'get');
console.log(res);
if (res.code === 200) {
@@ -166,7 +164,10 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
setTimeout(()=>{
this.getDeviceDetail();
},0)
},
/**
@@ -183,7 +184,7 @@ Page({
return {
title:"我分享了一个设备。",
path:`/pages/4Gswitch/index?deviceInfo=${JSON.stringify(e.target.dataset.info)}&&isShare=1`,
imageUrl:'/icons/smart.jpg'
imageUrl:'/icons/light.png'
}
}
})

View File

@@ -20,9 +20,12 @@ Page({
})
},
addWifi(){
wx.showToast({
title: '暂不支持',
icon:'error'
// wx.showToast({
// title: '暂不支持',
// icon:'error'
// })
wx.navigateTo({
url: '/pages/addWiFi/index',
})
},
})

View File

@@ -0,0 +1,279 @@
const alreadyConnected = 'target wifi is already connected.';
Page({
data: {
pwdHide:true,
ssid: '',
password: '',
deviceSSID:'Shgf',
devicePWD:'12345678',
// deviceSSID:'XiaoYi_IOT_AirBox',
// devicePWD:'asdqwe9867',
udp: '',
port: 0,
showClearBtn: false,
isFirst: true,
stepsTop: [
{ text: '步骤一',desc: '连接WiFi', },
{ text: '步骤二',desc: '连接软热点', },
{ text: '步骤三',desc: '开始配网', }
],
steps: [
{ text: '手机与设备通信成功',success:false },
{ text: '设备配网成功',success:false },
{ text: '切换回家庭WiFi',success:false }
],
activeTop:0,
active:-1
},
onLoad(opt) {
let that = this;
try {
let udp = this.data.udp;
udp.offListening();
udp.offMessage();
udp.offClose();
udp.close();
} catch (error) {
console.log(error);
}
wx.startWifi({
success(res) {
console.log(res.errMsg, 'wifi初始化成功')
that.getWifiInfo();
},
fail: function (res) {
wx.showToast({
title: '请连接路由器!',
duration: 2000,
icon: 'none'
})
}
})
},
getWifiInfo() {
let that = this
wx.getConnectedWifi({
success(res) {
console.log("getConnectedWifi ok:", JSON.stringify(res))
if ('getConnectedWifi:ok' === res.errMsg) {
that.setData({
ssid: res.wifi.SSID,
bssid: res.wifi.BSSID
})
} else {
wx.showToast({
title: '请连接路由器',
duration: 2000,
icon: 'none'
})
}
},
fail(res) {
wx.showToast({
title: '请连接路由器',
duration: 2000,
icon: 'none'
})
}
})
},
onConfirm() {
const that = this;
console.log("ssid:", this.data.ssid, ",password:", this.data.password,',port:',this.data.port);
that.udpConnect();
if ((this.data.ssid.trim() === '') || (this.data.password.trim() === '')) {
wx.showToast({
title: '请输入完整',
icon:'error'
});
return;
}
that.setData({ activeTop:++that.data.activeTop });
// that.udpConnect();
},
udpConnect(){
const udp = wx.createUDPSocket();
udp.onListening(res => {
console.log('正在监听...');
})
const password = this.data.password;
const ssid = this.data.ssid;
let message = JSON.stringify({
port,
password,
ssid
});
let port = udp.bind(50314);
console.log(udp,udp.onListening,udp.send);
console.log('port',port);
// setInterval(() => {
// udp.send({
// address:'255.255.255.255',
// port:8081,
// message
// });
// }, 2000);
console.log(message);
udp.onMessage((res) => {
console.log('res:',res)
//字符串转换,很重要
let unit8Arr = new Uint8Array(res.message);
let encodedString = String.fromCharCode.apply(null, unit8Arr);
let dat = decodeURIComponent(escape((encodedString)));
console.log("data:", dat);
let str = JSON.parse(dat);
console.log(str);
switch (str.code) {
//成功收到信息
case 0:
udp.send({
address:'255.255.255.255',
port:8081,
message
});
let steps = this.data.steps;
steps[0].success = true;
this.setData({ steps });
break;
//成功解析到信息
case 1:
udp.send({
address:'255.255.255.255',
port:8081,
message:'I GOT YOU'
});
steps = this.data.steps;
steps[1].success = true;
this.setData({ steps });
udp.offListening();
udp.offMessage();
udp.offClose();
udp.close();
wx.connectWifi({
SSID: ssid,
password: password,
success:()=>{
wx.onWifiConnected((result) => {
let steps = this.data.steps;
steps[2].success = true;
this.setData({ steps });
wx.hideLoading()
const newUdp = wx.createUDPSocket();
const newPort = newUdp.bind(50314);
newUdp.onListening(res => {
console.log('再次监听中。。。');
});
newUdp.onMessage(re => {
let _unit8Arr = new Uint8Array(re.message);
let _encodedString = String.fromCharCode.apply(null, _unit8Arr);
let _dat = decodeURIComponent(escape((_encodedString)));
console.log("data:", _dat);
newUdp.send({
address:'255.255.255.255',
port:8081,
message:'BIND SUCCESS !'
});
newUdp.offListening();
newUdp.offMessage();
newUdp.offClose();
newUdp.close();
})
});
wx.showToast({
title: '准备连接路由器',
})
}
});
break;
//成功连接到路由器
// case 2:
// wx.showToast({
// title: '成功连接',
// })
// break;
// //连接失败路由器
// case 3:
// wx.showToast({
// title: '连接失败',
// })
// break;
}
})
},
lookPwd(){
let pwdHide = !this.data.pwdHide;
this.setData({ pwdHide });
},
inputPwd(e){
this.setData({ password:e.detail.value })
},
inputDevicePWD(e){
this.setData({ devicePWD:e.detail.value })
},
inputAcc(e){
this.setData({ ssid:e.detail.value })
},
inputDeviceSSID(e){
this.setData({ deviceSSID:e.detail.value })
},
onConnect(){
const that = this;
wx.showLoading({
title: '连接中',
mask:true
})
console.log("ssid:", this.data.deviceSSID, ",password:", this.data.devicePWD);
wx.connectWifi({
SSID: this.data.deviceSSID,
password: this.data.devicePWD,
}).then((res)=>{
console.log(res);
// if (res.wifiMsg===alreadyConnected) {
// wx.hideLoading();
// that.udpConnect();
// }else{
// wx.onWifiConnected((result) => {
// wx.hideLoading();
// // that.setData({ active:++that.data.active });
// that.udpConnect();
// })
// }
}).catch((err)=>{
wx.hideLoading();
wx.showToast({
title: '连接失败',
icon:'error'
})
console.error(err);
});
wx.onWifiConnected((result) => {
wx.hideLoading();
that.setData({ activeTop:++that.data.activeTop });
that.udpConnect();
})
},
closeUDP(){
this.data.udp.close();
},
onUnload(){
try {
let udp = this.data.udp;
udp.offListening();
udp.offMessage();
udp.offClose();
udp.close();
} catch (error) {
// console.error(error);
}
},
onShow(){
this.getWifiInfo();
}
});

View File

@@ -0,0 +1,7 @@
{
"usingComponents": {
"van-steps": "@vant/weapp/steps/index",
"van-button": "@vant/weapp/button/index",
"van-loading": "@vant/weapp/loading/index"
}
}

View File

@@ -0,0 +1,70 @@
<van-steps steps="{{ stepsTop }}" active="{{ activeTop }}" />
<view class='teach'>
<image src='/icons/route.png' />
<view class=''>第一步输入家庭WiFi信息</view>
<view class=''>第二步,连接设备热点</view>
<view class=''>第三步重新连接家庭WiFi</view>
</view>
<br />
<br />
<block wx:if='{{ activeTop === 0 }}'>
<view class='form'>
<view class='title'>
输入家庭WiFi信息
</view>
<label class='account'>
<image class='icon' src='/icons/wifi.png' />
<input type='text' bind:input='inputAcc' value='{{ ssid }}' placeholder='请输入WiFi名称' />
</label>
<label class='password'>
<image class='icon' src='/icons/pwd.png' />
<input wx:if='{{ pwdHide === true }}' bind:input='inputPwd' value='{{ password }}' type='password' placeholder='请输入密码' />
<input wx:if='{{ pwdHide === false }}' bind:input='inputPwd' value='{{ password }}' type='text' placeholder='请输入密码' />
<view class='icon' bindtap='lookPwd'>
<image wx:if='{{ pwdHide === true }}' class='icon' src='/icons/close.png' />
<image wx:if='{{ pwdHide === false }}' class='icon' src='/icons/open.png' />
</view>
</label>
<view class='btn'>
<van-button block round color="linear-gradient(to right, #4bb0ff, #6149f6)" bind:click='onConfirm'>
下一步
</van-button>
</view>
</view>
</block>
<block wx:if='{{ activeTop === 1 }}'>
<view class='form'>
<view class='title'>
连接设备热点
</view>
<label class='account'>
<image class='icon' src='/icons/acc.png' />
<input type='text' disabled bind:input='inputDeviceSSID' value='{{ deviceSSID }}' placeholder='请输入设备热点名称' />
</label>
<label class='password'>
<image class='icon' src='/icons/pwd.png' />
<input wx:if='{{ pwdHide === true }}' disabled bind:input='inputDevicePWD' value='{{ devicePWD }}' type='password' placeholder='请输入密码' />
<input wx:if='{{ pwdHide === false }}' disabled bind:input='inputDevicePWD' value='{{ devicePWD }}' type='text' placeholder='请输入密码' />
<view class='icon' bindtap='lookPwd'>
<image wx:if='{{ pwdHide === true }}' class='icon' src='/icons/close.png' />
<image wx:if='{{ pwdHide === false }}' class='icon' src='/icons/open.png' />
</view>
</label>
<view class='btn'>
<van-button block round color="linear-gradient(to right, #4bb0ff, #6149f6)" bind:click='onConnect'>
连接
</van-button>
</view>
</view>
</block>
<block wx:if='{{ activeTop === 2 }}'>
<view class='step'>
<view class='item' wx:for='{{ steps }}'>
<van-loading wx:if='{{ item.success === false }}' type="spinner" />
<image wx:if='{{ item.success === true }}' src='/icons/yes.png' />
<text class='desc'>{{ item.text }}</text>
</view>
</view>
<button bindtap='closeUDP'>关闭</button>
</block>

View File

@@ -0,0 +1,52 @@
/* pages/index/index.wxss */
.form{
width:80vw;
margin:0 auto;
}
.title{
font-size:38rpx;
}
label{
display:flex;
align-items:center;
padding:35rpx 0;
border-bottom:2rpx solid #bfbfbf;
}
.icon{
width:40rpx;
height:40rpx;
display:flex;
align-items:center;
justify-content:center;
}
input{
padding:15rpx 30rpx;
flex:1
}
.btn{
width:80%;
margin:30rpx auto;
}
.teach{
display:flex;
flex-direction:column;
align-items:center;
margin:0 0 30rpx 0;
}
.step{
margin:30rpx auto ;
width:50%;
}
.item{
display:flex;
align-items:center;
margin:15rpx 0;
}
.item>image{
width:48rpx;
height:48rpx;
border-radius:50%;
}
.desc{
padding:0 15rpx;
}

View File

@@ -0,0 +1,115 @@
// pages/feedBack/feedBack.js
const { request } = require('../../API/request');
Page({
/**
* 页面的初始数据
*/
data: {
selectData:[
{ id:1,text:'程序bug' },
{ id:2,text:'内容意见' },
{ id:3,text:'网络问题' },
{ id:4,text:'功能建议' },
{ id:5,text:'其他' }
],
maxlength:200,
radio: 1,
value:'',
tempFilePaths:[],
phoneNum:'',
lengthErr:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.setNavigationBarTitle({
title: '意见反馈'
});
wx.setNavigationBarColor({
backgroundColor: '#58bcff',
frontColor: '#ffffff',
})
},
checkOne(e){
this.setData({
radio:e.detail
})
},
inputDetail(e){
if (e.detail.value.trim().length >= 15) {
this.setData({
lengthErr:false
})
}
this.setData({
value:e.detail.value
})
},
chooseImage(){
const that = this;
let tempFilePaths = this.data.tempFilePaths;
wx.chooseImage({
count: 3,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: (result) => {
that.setData({
tempFilePaths:tempFilePaths.concat(result.tempFilePaths)
})
}
})
},
previewImage(e){
console.log(e);
wx.previewImage({
urls: this.data.tempFilePaths,
current:this.data.tempFilePaths[e.currentTarget.dataset.index]
})
},
deleteImage(e){
let tempFilePaths = this.data.tempFilePaths;
tempFilePaths.splice(e.currentTarget.dataset.index,1);
this.setData({
tempFilePaths
})
},
inputNum(e){
this.setData({
phoneNum:e.detail.value
})
},
async submit(){
const tempFilePaths = this.data.tempFilePaths;
const describe = this.data.value;
const phone = this.data.phoneNum;
const radio = this.data.radio;
if(describe.trim().length < 15){
this.setData({
lengthErr:true
})
return;
}
const res = await request('','post',{
phone,
tempFilePaths,
describe,
type:this.data.selectData[radio-1]
});
if (res.code === 200) {
wx.switchTab({
url: '/pages/my/my',
})
}
}
})

View File

@@ -0,0 +1,3 @@
{
"usingComponents": {}
}

View File

@@ -0,0 +1,59 @@
<!--pages/feedBack/feedBack.wxml-->
<view class="checkbox">
<view class="title">选择反馈类型</view>
<van-radio-group
value="{{ radio }}"
bind:change="onChange"
direction="horizontal"
bind:change="checkOne"
>
<van-radio wx:for="{{ selectData }}" name="{{ item.id }}" >{{ item.text }}</van-radio>
</van-radio-group>
</view>
<view class="input">
<view class="main">
<textarea placeholder="请输入15~200字的问题描述"
value="{{ value }}" maxlength='{{ maxlength }}'
bindinput="inputDetail">
</textarea>
<view class="addImage">
<view class="add">
<image bindtap="chooseImage" src="/icons/add_1.png" />
</view>
<view class="imgs">
<view class="item" wx:for="{{ tempFilePaths }}" wx:key='index'>
<image bindtap="previewImage" data-index='{{ index }}' src="{{ item }}" />
<view class="delete">
<image src="/icons/delete.png" bindtap="deleteImage" data-index="{{ index }}" />
</view>
</view>
</view>
</view>
</view>
<view class="length">
<text>{{ value.length }}</text>
<text>/</text>
<text>{{ maxlength }}</text>
</view>
<view wx:if="{{ lengthErr }}" class="errMsg {{ lengthErr && 'Vibration' }}">
<text style="color:#ff0000;">请至少输入15个字符</text>
</view>
</view>
<view class="phone">
<view class="title">联系方式(选填)</view>
<view class="inputPhone">
<view class="icon">
<image src="/icons/phone.png" />
</view>
<input type="number" placeholder="请输入手机号" value="{{ phoneNum }}" bindtap="inputNum" />
</view>
</view>
<view class="btn">
<van-button block color='#58bcff' round bindtap="submit">默认按钮</van-button>
</view>

View File

@@ -0,0 +1,138 @@
/* pages/feedBack/feedBack.wxss */
.checkbox{
width: calc(100vw - 120rpx);
padding: 30rpx;
box-shadow: 0 0 12rpx #bfbfbf;
margin: 30rpx auto 15rpx;
background-color: #ffffff;
}
.title{
color: #9e9e9e;
padding-bottom: 15rpx;
}
.van-radio{
margin: 15rpx 0;
}
.length{
color: #9e9e9e;
float: right;
}
.input{
width: calc(100vw - 120rpx);
padding: 30rpx;
box-shadow: 0 0 12rpx #bfbfbf;
margin: 15rpx auto;
background-color: #ffffff;
}
.main{
box-shadow: 0 0 5rpx #bfbfbf;
}
textarea{
padding:15rpx;
height: 150rpx;
width: calc(100% - 30rpx);
}
.phone{
width: calc(100vw - 120rpx);
padding: 15rpx 30rpx;
box-shadow: 0 0 12rpx #bfbfbf;
margin: 15rpx auto;
background-color: #ffffff;
}
.inputPhone{
display: flex;
align-items: center;
}
.inputPhone>input{
padding: 10rpx 30rpx;
border-bottom: 2rpx solid #bfbfbf;
margin: 0 30rpx;
}
.addImage{
display: flex;
}
.add{
width: 100rpx;
height: 100rpx;
border: 4rpx dashed #aaaaaa;
margin: 15rpx;
display: flex;
justify-content: center;
align-items: center;
}
.add>image{
width: 50%;
height: 50%;
}
.add>image:active{
width: 45%;
height: 45%;
}
.imgs{
display: flex;
flex-wrap: wrap;
}
.item{
width: 100rpx;
height: 100rpx;
border: 2rpx solid #8a8a8a;
margin: 15rpx;
position: relative;
}
.item>image{
width: 100%;
height: 100%;
}
.delete{
position: absolute;
right: 0;
top: 0;
width: 30rpx;
height: 30rpx;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
background-color: #ff1515;
transform: translate(50%,-50%);
border:1rpx solid #666;
}
.delete>image{
width: 100%;
height: 100%;
}
.icon{
width: 50rpx;
height: 50rpx;
}
.icon>image{
width: 100%;
height: 100%;
}
.btn{
width: calc(100vw - 60rpx);
padding: 30rpx;
}
.Vibration{
animation: Vibration 0.3s 1;
}
@keyframes Vibration{
0% {
transform: translateX(0);
}
25% {
transform: translateX(-10rpx);
}
50% {
transform: translateX(10rpx);
}
75% {
transform: translateX(10rpx);
}
100% {
transform: translateX(-10rpx);
}
}

View File

@@ -30,5 +30,8 @@
<van-cell title="公司简介" size="large" icon='/icons/jianjie.png' is-link/>
<van-cell title="关于我们" size="large" icon='/icons/about.png' is-link/>
<van-cell title="加入我们" size="large" icon='/icons/join.png' is-link/>
<van-cell title="意见反馈" size="large" icon='/icons/suggest.png' is-link
url='/pages/feedBack/feedBack' link-type='navigateTo'
/>
</van-cell-group>
</view>

View File

@@ -32,6 +32,11 @@
"referrerInfo": {
"appId": "xxx"
}
},
{
"name": "pages/feedBack/feedBack",
"pathName": "pages/feedBack/feedBack",
"scene": null
}
]
}