Browse Source

'小程序配置'

develop
liwei 3 years ago
parent
commit
4a2b5efa94
22 changed files with 252 additions and 108 deletions
  1. +9
    -4
      app.js
  2. +23
    -8
      app.json
  3. +1
    -7
      app.wxss
  4. +55
    -0
      pages/authorization/authorization.js
  5. +4
    -0
      pages/authorization/authorization.json
  6. +1
    -1
      pages/authorization/authorization.wxml
  7. +0
    -0
      pages/authorization/authorization.wxss
  8. +86
    -0
      pages/basicInformation/basicInformation.js
  9. +4
    -0
      pages/basicInformation/basicInformation.json
  10. +54
    -0
      pages/basicInformation/basicInformation.wxml
  11. +7
    -0
      pages/basicInformation/basicInformation.wxss
  12. +0
    -49
      pages/index/index.js
  13. +0
    -3
      pages/index/index.json
  14. +0
    -18
      pages/logs/logs.js
  15. +0
    -4
      pages/logs/logs.json
  16. +0
    -6
      pages/logs/logs.wxml
  17. +0
    -8
      pages/logs/logs.wxss
  18. +3
    -0
      pages/questionnaire/questionnaire.js
  19. +4
    -0
      pages/questionnaire/questionnaire.json
  20. +1
    -0
      pages/questionnaire/questionnaire.wxml
  21. +0
    -0
      pages/questionnaire/questionnaire.wxss
  22. +0
    -0
      tsconfig.json

+ 9
- 4
app.js View File

@ -6,10 +6,15 @@ App({
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
wx.checkSession({
success (e) {
//session_key 未过期,并且在本生命周期一直有效
console.log('有效', e)
},
fail (e) {
// session_key 已经失效,需要重新执行登录流程
console.log('失效', e)
// wx.login() //重新登录
}
})
},


+ 23
- 8
app.json View File

@ -1,14 +1,29 @@
{
"pages":[
"pages/index/index",
"pages/logs/logs"
"pages": [
"pages/basicInformation/basicInformation",
"pages/authorization/authorization"
],
"window":{
"backgroundTextStyle":"light",
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle":"black"
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
"sitemapLocation": "sitemap.json",
"plugins": {
"WechatSI": {
"version": "0.3.4",
"provider": "wx069ba97219f66d99"
},
"ocr-plugin": {
"version": "3.0.6",
"provider": "wx4418e3e031e551be"
}
}
}

+ 1
- 7
app.wxss View File

@ -1,10 +1,4 @@
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
padding: 0 10px;
}

+ 55
- 0
pages/authorization/authorization.js View File

@ -0,0 +1,55 @@
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
canIUseGetUserProfile: false,
canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
},
getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: '授权登录', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
// 授权成功关闭当前页面,跳转至基础信息登记页面
wx.redirectTo({
url: '../basicInformation/basicInformation'
})
}
})
},
// 分享朋友
onShareAppMessage: (res) => {
return {
title: '业主思维',
path: '/pages/index/index',
imageUrl: "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D450%2C600/sign=e98512f3b5fd5266a77e34109e28bb1d/8d5494eef01f3a2945bbcbd69a25bc315c607cb2.jpg",
success: (res) => {
console.log("转发成功", res);
},
fail: (res) => {
console.log("转发失败", res);
}
}
},
// 分享朋友圈
onShareTimeline: (res) => {
return {
title: '业主思维',
path: '/pages/index/index',
imageUrl: "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D450%2C600/sign=e98512f3b5fd5266a77e34109e28bb1d/8d5494eef01f3a2945bbcbd69a25bc315c607cb2.jpg",
success: (res) => {
console.log("转发成功", res);
},
fail: (res) => {
console.log("转发失败", res);
}
}
}
})

+ 4
- 0
pages/authorization/authorization.json View File

@ -0,0 +1,4 @@
{
"navigationBarTitleText": "授权",
"usingComponents": {}
}

pages/index/index.wxml → pages/authorization/authorization.wxml View File

@ -1,4 +1,4 @@
<!--index.wxml-->
<!--授权-->
<view class="container">
<view class="userinfo">
<block wx:if="{{canIUseOpenData}}" calss="userinfo-opendata">

pages/index/index.wxss → pages/authorization/authorization.wxss View File


+ 86
- 0
pages/basicInformation/basicInformation.js View File

@ -0,0 +1,86 @@
var plugin = requirePlugin("WechatSI")
let manager = plugin.getRecordRecognitionManager()
Page({
data: {
scrollTop: '0',
formData: {
switch: true,
radio: 'radio1'
},
loading: true,
text: ''
},
formSubmit(e) {
console.log('form发生了submit事件,携带数据为:', e.detail.value)
},
formReset(e) {
console.log('form发生了reset事件,携带数据为:', e.detail.value)
this.setData({
chosen: ''
})
},
onShareAppMessage: (res) => {
return {
title: '业主思维',
path: '/pages/index/index',
imageUrl: "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D450%2C600/sign=e98512f3b5fd5266a77e34109e28bb1d/8d5494eef01f3a2945bbcbd69a25bc315c607cb2.jpg",
success: (res) => {
console.log("转发成功", res);
},
fail: (res) => {
console.log("转发失败", res);
}
}
},
onShareTimeline: (res) => {
return {
title: '业主思维',
path: '/pages/index/index',
imageUrl: "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D450%2C600/sign=e98512f3b5fd5266a77e34109e28bb1d/8d5494eef01f3a2945bbcbd69a25bc315c607cb2.jpg",
success: (res) => {
console.log("转发成功", res);
},
fail: (res) => {
console.log("转发失败", res);
}
}
},
onLoad(){
wx.request({
url: 'http://101.201.121.115:8093/user/getuserinfo', //仅为示例,并非真实的接口地址
data: {
x: '',
y: ''
},
header: {
'content-type': 'application/json' // 默认值
},
success (res) {
console.log(res.data)
}
})
wx.getSetting({
success(res) {
// 校验用户是否已经授权
if (res.authSetting['scope.userInfo']) {
// 必须是在用户已经授权的情况下调用
wx.getUserInfo({
success: function (res) {
console.log(res)
}
})
}else{
// 如果未授权则关闭所有页面,跳转至授权登录页
wx.reLaunch({
url: '/pages/authorization/authorization'
})
}
}
})
}
})

+ 4
- 0
pages/basicInformation/basicInformation.json View File

@ -0,0 +1,4 @@
{
"navigationBarTitleText": "基础信息",
"usingComponents": {}
}

+ 54
- 0
pages/basicInformation/basicInformation.wxml View File

@ -0,0 +1,54 @@
<!--基础信息维护-->
<view class="container">
<view class="page-body">
<form catchsubmit="formSubmit" catchreset="formReset">
<view class="page-section page-section-gap">
<view class="page-section-title">switch</view>
<switch name="switch" checked="{{ formData.switch }}" />
</view>
<view class="page-section page-section-gap">
<view class="page-section-title">radio</view>
<radio-group name="radio">
<label>
<radio value="radio1" />选项一
</label>
<label>
<radio value="radio2" checked="{{formData.radio}}" />选项二
</label>
</radio-group>
</view>
<view class="page-section page-section-gap">
<view class="page-section-title">checkbox</view>
<checkbox-group name="checkbox">
<label>
<checkbox value="checkbox1" checked="{{true}}}" />选项一
</label>
<label>
<checkbox value="checkbox2" checked="{{true}}" />选项二
</label>
</checkbox-group>
</view>
<view class="page-section page-section-gap">
<view class="page-section-title">slider</view>
<slider value="50" name="slider" show-value></slider>
</view>
<view class="page-section">
<view class="page-section-title">input</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell weui-cell_input">
<view class="weui-cell__bd" style="margin: 30rpx 0">
<input placeholder-style="color:red;" class="weui-cell__text" placeholder="请输入内容" name="input"
value="{{text}}" />
</view>
</view>
</view>
</view>
<button type="primary" bindtouchstart="touchStartC" bindtouchend="touchEndC">{{loading?'按住说话':'正在识别'}}</button>
<view class="btn-area">
<button style="margin: 30rpx 0" type="primary" formType="submit">Submit</button>
<button style="margin: 30rpx 0" formType="reset">Reset</button>
</view>
</form>
</view>
</view>

+ 7
- 0
pages/basicInformation/basicInformation.wxss View File

@ -0,0 +1,7 @@
.ocr-wrapper {
margin: 40rpx auto;
width: 375rpx;
}
.intro {
margin: 40rpx;
}

+ 0
- 49
pages/index/index.js View File

@ -1,49 +0,0 @@
// index.js
// 获取应用实例
const app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
canIUseGetUserProfile: false,
canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
},
// 事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad() {
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
},
getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
getUserInfo(e) {
// 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息
console.log(e)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})

+ 0
- 3
pages/index/index.json View File

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

+ 0
- 18
pages/logs/logs.js View File

@ -1,18 +0,0 @@
// logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad() {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return {
date: util.formatTime(new Date(log)),
timeStamp: log
}
})
})
}
})

+ 0
- 4
pages/logs/logs.json View File

@ -1,4 +0,0 @@
{
"navigationBarTitleText": "查看启动日志",
"usingComponents": {}
}

+ 0
- 6
pages/logs/logs.wxml View File

@ -1,6 +0,0 @@
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log.date}}</text>
</block>
</view>

+ 0
- 8
pages/logs/logs.wxss View File

@ -1,8 +0,0 @@
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}

+ 3
- 0
pages/questionnaire/questionnaire.js View File

@ -0,0 +1,3 @@
Page({
})

+ 4
- 0
pages/questionnaire/questionnaire.json View File

@ -0,0 +1,4 @@
{
"navigationBarTitleText": "问卷调查",
"usingComponents": {}
}

+ 1
- 0
pages/questionnaire/questionnaire.wxml View File

@ -0,0 +1 @@
<page-meta scroll-top="{{scrollTop}}"></page-meta>

+ 0
- 0
pages/questionnaire/questionnaire.wxss View File


+ 0
- 0
tsconfig.json View File


Loading…
Cancel
Save