Skip to content

Commit

Permalink
项目初始化提交
Browse files Browse the repository at this point in the history
  • Loading branch information
彭永波 committed Jun 28, 2018
0 parents commit 32f6306
Show file tree
Hide file tree
Showing 27 changed files with 1,029 additions and 0 deletions.
39 changes: 39 additions & 0 deletions app.js
@@ -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
}
})
36 changes: 36 additions & 0 deletions app.json
@@ -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": "联系"
}]
}


}
5 changes: 5 additions & 0 deletions app.wxss
@@ -0,0 +1,5 @@
/**app.wxss**/
page,.page{
width:100%;
height:100%;
}
Binary file added images/active.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/appointment.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/arrow.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/banner_01.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/banner_02.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/banner_03.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/banner_04.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/compose.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/contact.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/date.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/home.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/time.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions pages/contact/contact.js
@@ -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);
}
23 changes: 23 additions & 0 deletions pages/contact/contact.wxml
@@ -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>
49 changes: 49 additions & 0 deletions pages/contact/contact.wxss
@@ -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;
}

0 comments on commit 32f6306

Please sign in to comment.