Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
彭永波
committed
Jun 28, 2018
0 parents
commit 32f6306
Showing
27 changed files
with
1,029 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//app.js | ||
App({ | ||
onLaunch: function () { | ||
// 展示本地存储能力 | ||
var logs = wx.getStorageSync('logs') || [] | ||
logs.unshift(Date.now()) | ||
wx.setStorageSync('logs', logs) | ||
|
||
// 登录 | ||
wx.login({ | ||
success: res => { | ||
// 发送 res.code 到后台换取 openId, sessionKey, unionId | ||
} | ||
}) | ||
// 获取用户信息 | ||
wx.getSetting({ | ||
success: res => { | ||
if (res.authSetting['scope.userInfo']) { | ||
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 | ||
wx.getUserInfo({ | ||
success: res => { | ||
// 可以将 res 发送给后台解码出 unionId | ||
this.globalData.userInfo = res.userInfo | ||
|
||
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | ||
// 所以此处加入 callback 以防止这种情况 | ||
if (this.userInfoReadyCallback) { | ||
this.userInfoReadyCallback(res) | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
}) | ||
}, | ||
globalData: { | ||
userInfo: null | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"pages": [ | ||
"pages/index/index", | ||
"pages/form/form", | ||
"pages/contact/contact" | ||
], | ||
"window": { | ||
"backgroundTextStyle": "light", | ||
"navigationBarBackgroundColor": "#6caae4", | ||
"navigationBarTitleText": "小程序测试", | ||
"navigationBarTextStyle": "black" | ||
}, | ||
"tabBar": { | ||
"color": "#a9b7b7", | ||
"selectedColor": "#11cd6e", | ||
"borderStyle": "white", | ||
"list": [{ | ||
"selectedIconPath": "images/home.png", | ||
"iconPath": "images/home.png", | ||
"pagePath": "pages/index/index", | ||
"text": "首页" | ||
}, { | ||
"selectedIconPath": "images/appointment.png", | ||
"iconPath": "images/appointment.png", | ||
"pagePath": "pages/form/form", | ||
"text": "预约" | ||
}, { | ||
"selectedIconPath": "images/contact.png", | ||
"iconPath": "images/contact.png", | ||
"pagePath": "pages/contact/contact", | ||
"text": "联系" | ||
}] | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/**app.wxss**/ | ||
page,.page{ | ||
width:100%; | ||
height:100%; | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
//add.js | ||
Page({ | ||
data: { | ||
|
||
}, | ||
|
||
onLoad: function(e) { | ||
|
||
var id = e.id; | ||
// console.log(id); | ||
if (id) { | ||
getData(id, this); | ||
} else { | ||
console.log("test") | ||
this.setData({ | ||
id: Date.now(), | ||
txtStyle: "", | ||
}) | ||
} | ||
|
||
}, | ||
change(e) { | ||
var val = e.detail.value; | ||
console.log(val); | ||
this.setData({ | ||
content: val | ||
}) | ||
}, | ||
cancel() { | ||
|
||
wx.navigateBack(); | ||
}, | ||
sure() { | ||
var re = /^\s*$/g; | ||
if (!this.data.content || re.test(this.data.content)) { | ||
wx.showToast({ | ||
title: `请填写完整内容在提交`, | ||
image: '/images/appointment.png', | ||
icon: 'fail' | ||
|
||
}) | ||
return false | ||
|
||
} | ||
this.setData({ | ||
time: Date.now() | ||
}) | ||
|
||
setvalue(this); | ||
// wx.navigateBack(); | ||
wx.switchTab({ | ||
url: '../list/list' | ||
}) | ||
}, | ||
getUserInfo: function(e) { | ||
console.log(e) | ||
app.globalData.userInfo = e.detail.userInfo | ||
this.setData({ | ||
userInfo: e.detail.userInfo, | ||
hasUserInfo: true | ||
}) | ||
} | ||
}) | ||
|
||
|
||
|
||
function getData(id, page) { | ||
|
||
var arr = wx.getStorageSync('txt'); | ||
|
||
if (arr.length) { | ||
arr.forEach((item) => { | ||
if (item.id == id) { | ||
page.setData({ | ||
id: item.id, | ||
content: item.content | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
} | ||
|
||
|
||
function setvalue(page) { | ||
|
||
var arr = wx.getStorageSync('txt'); | ||
|
||
var data = [], | ||
flag = true; | ||
|
||
if (arr.length) { | ||
arr.forEach((item) => { | ||
|
||
if (item.id == page.data.id) { | ||
item.time = Date.now(); | ||
item.content = page.data.content; | ||
flag = false; | ||
} | ||
data.push(item); | ||
}) | ||
} | ||
|
||
if (flag) { | ||
|
||
data.push(page.data); | ||
} | ||
wx.setStorageSync('txt', data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!--index.wxml--> | ||
<view class="page"> | ||
<view class="page-t"> | ||
|
||
<text class="ar_cont_h1">联系方式</text> | ||
|
||
<view class="drawer_title line"> | ||
<image src="../../images/contact.png"></image> | ||
地址:天津市和平11号 | ||
</view> | ||
<view class="drawer_title line"> | ||
<image src="../../images/appointment.png"></image> | ||
手机:13456788890 | ||
</view> | ||
<view class="drawer_title line"> | ||
<image src="../../images/appointment.png"></image> | ||
微信:bbnbs1234567 | ||
</view> | ||
</view> | ||
|
||
|
||
|
||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/**index.wxss**/ | ||
|
||
.page { | ||
displey: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.page-t { | ||
width: 100%; | ||
height: 90%; | ||
} | ||
|
||
.page-t .ar_cont_h1 { | ||
font-size: 32rpx; | ||
font-weight: 600; | ||
line-height: 64rpx; | ||
color: #000; | ||
padding: 20rpx 0; | ||
display: block; | ||
text-align: center; | ||
} | ||
|
||
.drawer_title { | ||
position: relative; | ||
padding: 20rpx; | ||
font: 32rpx "microsoft yahei"; | ||
text-align: center; | ||
color: #666; | ||
margin: 20rpx auto; | ||
} | ||
|
||
.line { | ||
border-bottom: 1px solid #f8f8f8; | ||
} | ||
|
||
.drawer_title:last-child { | ||
border-bottom: none; | ||
} | ||
|
||
.drawer_title image { | ||
width: 50rpx; | ||
height: 50rpx; | ||
position: absolute; | ||
display: inline-block; | ||
top: -2rpx; | ||
left: 170rpx; | ||
text-align: center; | ||
margin-top: 22rpx; | ||
} |
Oops, something went wrong.