作者 乔蒙蒙

锐网

正在显示 59 个修改的文件 包含 2318 行增加98 行删除

要显示太多修改。

为保证性能只显示 59 of 59+ 个文件。

//app.js
App({
data: {
minscreenHeight: 0,
},
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
this.getHeight(1)
},
getHeight: function (n) {
var _this = this;
wx.getSystemInfo({
success: function (res) {
_this.data.minscreenHeight = res.windowHeight * n
}
})
// 获取用户信息
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)
}
},
goTop: function () {
wx.pageScrollTo({
scrollTop: 0,
duration: 100
})
},
/**
* 自定义post函数,返回Promise
* +-------------------
* @param {String} url 接口网址
* @param {arrayObject} data 要传的数组对象 like: {name: 'name', age: 32}
* +-------------------
* @return {Promise} promise 返回promise供后续操作
*/
post: function (url, data, headerParams) {
wx.showNavigationBarLoading()
wx.showLoading({
title: '加载中',
})
var promise = new Promise((resolve, reject) => {
let that = this;
let postData = data;
let baseUrl = 'http://ruiwechat.w.bronet.cn/';
//网络请求
let header = {
'content-type': 'application/x-www-form-urlencoded'
}
header = Object.assign(header, headerParams)
wx.request({
url: baseUrl + url,
data: postData,
method: 'POST',
header: header,
success: function (res) {//返回取得的数据
if (res.data.code == '200') {
resolve(res.data.data);
} else if (res.data.code == '10001') {//用户未
// wx.showModal({
// title: '提示',
// content: res.data.msg,
// showCancel: false,
// success: function (res) {
// if (res.confirm) {
// wx.removeStorageSync('token');
// wx.navigateTo({
// url: '/pages/start/start',
// })
// }
// }
// })
} else if (res.data.code == '40000') {
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
success: function (res) { }
})
} else if (res.data.code == '40005') {
} else if (res.data.code == '40006') {
} else {
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
})
reject(res.data)
}
wx.hideLoading()
wx.hideNavigationBarLoading()
},
error: function (e) {
console.log(e)
reject('网络出错');
// wx.hideLoading()
wx.hideNavigationBarLoading()
}
})
});
return promise;
},
globalData: {
userInfo: null
}
},
// 动画
//渐入,渐出实现
show: function (that, param, opacity) {
var animation = wx.createAnimation({
//持续时间800ms
duration: 800,
timingFunction: 'ease',
});
//var animation = this.animation
animation.opacity(opacity).step()
//将param转换为key
var json = '{"' + param + '":""}'
json = JSON.parse(json);
json[param] = animation.export()
//设置动画
that.setData(json)
},
//滑动渐入渐出
slideupshow: function (that, param, px, opacity) {
var animation = wx.createAnimation({
duration: 1000,
timingFunction: 'ease',
});
animation.translateY(px).opacity(opacity).step()
//将param转换为key
var json = '{"' + param + '":""}'
json = JSON.parse(json);
json[param] = animation.export()
//设置动画
that.setData(json)
},
//向右滑动渐入渐出
sliderightshow: function (that, param, px, opacity) {
var animation = wx.createAnimation({
duration: 1500,
timingFunction: 'ease',
});
animation.translateX(px).opacity(opacity).step()
//将param转换为key
var json = '{"' + param + '":""}'
json = JSON.parse(json);
json[param] = animation.export()
//设置动画
that.setData(json)
},
})
\ No newline at end of file
... ...
{
"pages":[
"pages": [
"pages/index/index",
"pages/about/about",
"pages/case/case",
"pages/caseDetail/caseDetail",
"pages/caseList/caseList",
"pages/application/application",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
"navigationBarTextStyle": "black"
}
}
... ...
/**app.wxss**/
page {
width: 100%;
height: 100%;
}
.container {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
/* padding: 200rpx 0; */
/* box-sizing: border-box; */
}
.drop_img {
width: 30rpx;
height: 27rpx;
cursor: pointer;
margin: 0 auto 40rpx;
}
.drop_img image {
width: 100%;
height: 100%;
}
/* 客服 */
.chat_peo {
position: fixed;
width: 86rpx;
height: 86rpx;
bottom: 80rpx;
right: 24rpx;
z-index: 10;
}
button::after {
border: none;
opacity: 0;
}
.contacButton {
background: none;
border: none;
padding: 0;
display:inline-block;
width:100%;
height:100%;
}
.chat_peo image {
width: 100%;
height: 100%;
}
/* 返回顶部 */
.return_top {
bottom: 187rpx;
}
/* 去除滚动条 */
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
... ...
// pages/about/about.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
connectButton: [
{ className: "", text: "在线客服", bindtap: "" }
],
minscreenHeight: 0,
scrollTop: 0,
},
onPageScroll: function (e) { // 获取滚动条当前位置
console.log(111);
console.log(e.scrollTop);
console.log(minscreenHeight);
this.setData({
scrollTop: e.scrollTop
})
},
goTop: function () {
app.goTop()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "关于我们"
}
\ No newline at end of file
... ...
<!--pages/about/about.wxml-->
<view class='about_wrap'>
<view class='about_top'>
<image src='../images/about.png'></image>
</view>
<view class='about_content'>
<image src='../images/about_content.png' mode="widthFix"></image>
</view>
<view class='about_contact_way'>
<view class='about_title'>
<image src='../images/phone.png'></image>
<view>联系我们</view>
</view>
<view class='about_contact_box'>
<view class='about_contact_list'>
<view>全国服务热线:</view>
<view class='about_contact_right'>400-6262-686</view>
</view>
<view class='about_contact_list'>
<view>销售咨询:</view>
<view class='about_contact_right'>kefu@riwon.com.cn</view>
</view>
<view class='about_contact_list'>
<view>天津运营中心:</view>
<view class='about_contact_right'>天津市华苑产业园榕苑路1号</view>
</view>
<view class='about_contact_list'>
<view>北京运营中心:</view>
<view class='about_contact_right'>北京亦庄经济开发区东经海三路天骥智谷33号楼4层</view>
</view>
</view>
</view>
<view class='sub_apply_box'>
<view class='sub_apply_title'>
<image src='../images/apply.png'></image>
</view>
<view class='sub_apply_list'>
<view class='sub_apply_must'>*</view>
<view class='sub_apply_input'>
<view class='sub_input_left'>
<image src='../images/user.png' mode="widthFix"></image>
</view>
<input type='text' maxlength='10' placeholder="请输入您的姓名" />
<text>姓名请输入不超过10个字</text>
</view>
</view>
<view class='sub_apply_list'>
<view class='sub_apply_must'>*</view>
<view class='sub_apply_input'>
<view class='sub_input_left'>
<image src='../images/input_phone.png' mode="widthFix"></image>
</view>
<input type='number' maxlength='11' placeholder="请输入您的联系方式" />
</view>
</view>
<view class='sub_apply_list'>
<view class='sub_apply_must'>*</view>
<view class='sub_apply_input'>
<view class='sub_input_left'>
<image src='../images/company.png' mode="widthFix"></image>
</view>
<input type='text' placeholder="请输入您的所在行业" />
</view>
</view>
<view class='sub_btn'>
<image src='../images/sub_btn.png'></image>
</view>
</view>
<!-- 客服 -->
<view class='chat_peo'>
<button open-type="contact" class='contacButton'>
<image src='../images/chat_peo.png'></image>
</button>
</view>
<!-- 返回顶部 -->
<view class='chat_peo return_top' wx:if="{{scrollTop>minscreenHeight}}" bindtap="goTop">
<image src='../images/dingbu.png'></image>
</view>
</view>
... ...
/* pages/about/about.wxss */
.about_wrap {
width: 100%;
height: 100%;
overflow: auto;
}
.about_top {
width: 100%;
height: 469rpx;
display: flex;
justify-content: center;
align-items: center;
}
.about_top image {
width: 690rpx;
height: 400rpx;
}
.about_content {
width: 100%;
box-sizing: border-box;
padding: 0 31rpx;
margin-top:30rpx;
}
.about_content image {
width: 100%;
height: 100%;
}
.about_content text {
font-size: 30rpx;
color: #4D4D4D;
}
.about_contact_way {
width:690rpx;
background:rgba(250,248,247,1);
border-radius:10rpx;
margin: 35rpx auto 100rpx;
box-sizing: border-box;
padding: 40rpx 30rpx;
}
.about_title {
width: 100%;
height: 44rpx;
display: flex;
justify-content: flex-start;
align-items: center;
font-size: 32rpx;
color: #F0830C;
}
.about_title image {
width: 44rpx;
height: 44rpx;
margin-right: 20rpx;
vertical-align: middle;
}
.about_contact_box {
font-size: 28rpx;
color: #4D4D4D;
line-height: 50rpx;
margin-top: 35rpx;
}
.about_contact_list {
display: flex;
justify-content: flex-start;
}
.about_contact_right {
flex: 1;
}
.sub_apply_box {
margin-bottom: 80rpx;
width: 100%;
}
.sub_apply_box .sub_apply_title {
width: 100%;
box-sizing: border-box;
padding: 0 30rpx;
height: 147rpx;
}
.sub_apply_title image {
width: 100%;
height: 100%;
}
.sub_apply_list {
width: 100%;
box-sizing: border-box;
padding: 0 30rpx;
margin-top: 40rpx;
display: flex;
justify-content: flex-start;
align-items: center;
}
.sub_apply_must {
font-size: 34rpx;
color: #E10202;
margin-right: 14rpx;
}
.sub_apply_input {
flex: 1;
height:90rpx;
background:rgba(245,244,242,1);
border-radius:10rpx;
display: flex;
justify-content: flex-start;
align-items: center;
position: relative;
}
.sub_apply_input.active {
border: 1px solid #E10202;
}
.sub_apply_input .sub_input_left {
width: 40rpx;
height: 100%;
margin-left: 33rpx;
display: flex;
align-items: center;
}
.sub_input_left image {
width: 100%;
}
.sub_apply_input input {
flex: 1;
height: 100%;
padding-left: 15rpx;
color: #999999;
font-size: 30rpx;
}
.sub_apply_input text {
position: absolute;
font-size: 24rpx;
color: #E10202;
height: 40rpx;
bottom: -40rpx;
left: 96rpx;
}
.sub_btn {
width:320rpx;
height:90rpx;
border-radius:10rpx;
margin: 40rpx auto 0;
}
.sub_btn image {
width: 100%;
height: 100%;
}
... ...
// pages/application/application.js
Page({
/**
* 页面的初始数据
*/
data: {
imgUrls: [
'../images/app_banner01.png',
'../images/app_banner01.png',
'../images/app_banner01.png',
],
autoplay: true,
interval: 5000,
duration: 1000,
circular: true,
currentSwiper: 0,
},
changeIndicatorDots(e) {
this.setData({
indicatorDots: !this.data.indicatorDots
})
},
changeAutoplay(e) {
this.setData({
autoplay: !this.data.autoplay
})
},
intervalChange(e) {
this.setData({
interval: e.detail.value
})
},
durationChange(e) {
this.setData({
duration: e.detail.value
})
},
swiperChange: function (e) {
this.setData({
currentSwiper: e.detail.current
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
jumpFun: function (e) {
wx.navigateTo({
url: '../about/about'
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
wx.navigateTo({
url: '../about/about'
})
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "政府案例"
}
\ No newline at end of file
... ...
<!--pages/application/application.wxml-->
<view class='app_lication_banner'>
<swiper
bindchange='swiperChange'
autoplay="{{autoplay}}"
interval="{{interval}}"
duration="{{duration}}"
circular="{{circular}}"
>
<block wx:for="{{imgUrls}}" wx:key>
<swiper-item>
<image src="{{item}}" class="slide-image" width="100%" height="100%" />
</swiper-item>
</block>
</swiper>
<view class="dots">
<block wx:for="{{imgUrls}}" wx:key="">
<view class="dot{{index == currentSwiper ? ' active' : ''}}"></view>
</block>
</view>
<!-- 跳转下一页 -->
<view class='drop_img' bindtap="jumpFun">
<image src='../images/drop.png'></image>
</view>
<!-- 客服 -->
<view class='chat_peo' bindtap="jumpFun">
<image src='../images/chat_peo.png'></image>
</view>
</view>
... ...
/* pages/application/application.wxss */
.app_lication_banner {
width: 100%;
height: 100%;
}
swiper {
width: 100%;
height: 100%;
}
swiper image {
width: 100%;
height: 100%;
}
.dots{
/* width: 156rpx; */
height: 36rpx;
display: flex;
flex-direction: row;
position: absolute;
left: 325rpx;
bottom: 100rpx;
}
/*未选中时的小圆点样式 */
.dot{
width: 16rpx;
height: 16rpx;
border-radius: 50%;
margin-right: 26rpx;
background-color:#CCCCCC;
}
/*选中以后的小圆点样式 */
.active{
width: 16rpx;
height: 16rpx;
border-radius:8rpx;
background-color: #FB7F47;
}
/* 跳转下一页 */
.drop_img {
position: absolute;
bottom: 40rpx;
left: 50%;
margin-left: -15rpx;
}
... ...
// pages/case/case.js
const app=getApp();
Page({
/**
* 页面的初始数据
*/
data: {
imgUrls: [
// '../images/banner.png',
// '../images/banner.png',
// '../images/banner.png',
],
currentSwiper: 0,
autoplay: true,
interval: 5000,
duration: 1000,
circular: true,
},
changeIndicatorDots(e) {
this.setData({
indicatorDots: !this.data.indicatorDots
})
},
changeAutoplay(e) {
this.setData({
autoplay: !this.data.autoplay
})
},
intervalChange(e) {
this.setData({
interval: e.detail.value
})
},
swiperChange: function (e) {
this.setData({
currentSwiper: e.detail.current
})
},
durationChange(e) {
this.setData({
duration: e.detail.value
})
},
getlist(){
let url ='portal/Api/index';
app.post(url,{}).then((res)=>{
// console.log('res',res);
if (res.type){
this.setData({
imgUrls: res.banner
})
}
}).catch((err)=>{
console.log(err);
})
},
caseDetailFun(e) {
wx.navigateTo({
url: '../caseDetail/caseDetail?id=' + e.currentTarget.dataset.id
})
},
goFun(e) {
wx.navigateTo({
url: '../caseList/caseList?html=' + e.currentTarget.dataset.html
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getlist();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
jumpFun: function (e) {
wx.navigateTo({
url: '../application/application'
})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
wx.navigateTo({
url: '../application/application'
})
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "锐网科技"
}
\ No newline at end of file
... ...
<!--pages/case/case.wxml-->
<view class='case_wrap'>
<!--banner -->
<view class='case_banner_box'>
<swiper bindchange='swiperChange'
indicator-dots="{{indicatorDots}}"
autoplay="{{autoplay}}"
interval="{{interval}}"
duration="{{duration}}"
circular="{{circular}}">
<block wx:for="{{imgUrls}}" wx:key>
<swiper-item>
<image src="{{item.url}}" data-id='{{item.category_id}}' bindtap='caseDetailFun' class="slide-image" width="100%" height="100%" />
</swiper-item>
</block>
</swiper>
<view class="dots">
<block wx:for="{{imgUrls}}" wx:key="">
<view class="dot{{index == currentSwiper ? ' active' : ''}}"></view>
</block>
</view>
</view>
<!--案例类型 -->
<view class='case_box'>
<view class='case_title'>
<view class='case_title_content'>
<view class='case_contnet_line'></view>
<view class='case_title_text'>案例类型</view>
</view>
</view>
<view class='case_content'>
<view class='case_list' data-html="政府案例" bindtap='goFun'>
<image src='../images/zhengfu.png'></image>
<view class='case_list_text'>政府</view>
</view>
<view class='case_list' data-html="地产案例" bindtap='goFun'>
<image src='../images/dichan.png'></image>
<view class='case_list_text'>地产</view>
</view>
<view class='case_list' data-html="制造案例" bindtap='goFun'>
<image src='../images/zhizao.png'></image>
<view class='case_list_text'>制造</view>
</view>
<view class='case_list' data-html="教育案例" bindtap='goFun'>
<image src='../images/jiaoyu.png'></image>
<view class='case_list_text'>教育</view>
</view>
<view class='case_list' data-html="金融案例" bindtap='goFun'>
<image src='../images/jinrong.png'></image>
<view class='case_list_text'>金融</view>
</view>
<view class='case_list' data-html="零售案例" bindtap='goFun'>
<image src='../images/lingshou.png'></image>
<view class='case_list_text'>零售</view>
</view>
</view>
<view class='drop_img' bindtap="jumpFun">
<image src='../images/drop.png'></image>
</view>
</view>
<!-- 客服 -->
<view class='chat_peo' >
<button open-type="contact" class='contacButton'>
<image src='../images/chat_peo.png'></image>
</button>
</view>
</view>
... ...
/* pages/case/case.wxss */
.case_wrap {
width: 100%;
height: 100%;
background: #F0EEED;
position: relative;
}
.case_wrap .case_banner_box {
width: 100%;
height: 540rpx;
background: #fff;
position: relative;
}
.case_wrap .case_banner_box swiper {
width: 100%;
height: 487rpx;
}
.case_wrap .case_banner_box image {
width: 100%;
height: 100%;
}
.dots{
/* width: 156rpx; */
/* height: 36rpx; */
display: flex;
flex-direction: row;
position: absolute;
left: 320rpx;
bottom: 20rpx;
/* margin-top: -18rpx; */
}
/*未选中时的小圆点样式 */
.dot{
width: 16rpx;
height: 16rpx;
border-radius: 50%;
margin-right: 26rpx;
background-color:#CCCCCC;
}
/*选中以后的小圆点样式 */
.active{
width: 16rpx;
height: 16rpx;
border-radius:8rpx;
background-color: #FB7F47;
}
/*案例css */
.case_box {
width: 100%;
height: 647rpx;
background: #fff;
position: absolute;
bottom: 0;
left: 0;
display: flex;
flex-direction: column;
}
.case_title {
width: 100%;
height: 112rpx;
display: flex;
justify-content: center;
align-items: center;
}
.case_title .case_title_content {
width:276rpx;
height: 100%;
position: relative;
}
.case_title_content .case_contnet_line {
position: absolute;
width:100%;
height:1rpx;
background:linear-gradient(90deg,rgba(240,131,12,1),rgba(230,0,18,1));
opacity:0.5;
left: 0;
top: 50%;
}
.case_title_content .case_title_text {
width: 142rpx;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
left: 50%;
margin-left: -76rpx;
background-color: #fff;
color: #000000;
font-size: 30rpx;
}
.case_content {
display: flex;
flex-wrap: wrap;
}
.case_content .case_list {
width: 194rpx;
height: 194rpx;
display: flex;
justify-content: center;
align-items: center;
color: #333333;
font-weight: 500;
font-size: 26rpx;
position: relative;
margin: 0 28rpx 30rpx;
border-radius:10rpx;
}
.case_list image {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
/* z-index: 0; */
}
.case_list_text {
position: absolute;
/* top: 50%;
left: 50%; */
}
... ...
// pages/caseDetail/caseDetail.js
// var WxParse = require('../../wxParse/wxParse.js');
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
imgUrls: [
// '../images/detail01.png',
// '../images/detail01.png',
// '../images/detail01.png',
],
currentSwiper: 0,
autoplay: true,
interval: 5000,
duration: 1000,
circular: true,
listStatus: 0,
data: {},
minscreenHeight: 0,
scrollTop: 0,
},
changeIndicatorDots(e) {
this.setData({
indicatorDots: !this.data.indicatorDots
})
},
changeAutoplay(e) {
this.setData({
autoplay: !this.data.autoplay
})
},
intervalChange(e) {
this.setData({
interval: e.detail.value
})
},
swiperChange: function (e) {
this.setData({
currentSwiper: e.detail.current
})
},
durationChange(e) {
this.setData({
duration: e.detail.value
})
},
toggleFun(e) {
this.setData({
listStatus: e.currentTarget.dataset.id
})
},
onPageScroll: function (e) { // 获取滚动条当前位置
this.setData({
scrollTop: e.scrollTop
})
},
goTop: function () {
app.goTop()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// console.log(options);
// let url = '/portal/Api/category';
// let data = {
// categoryId: options.id,
// };
// app.post(url, data).then((res) => {
// // console.log('res', res);
// if (res.type) {
// this.setData({
// imgUrls: res.banner,
// data: res,
// });
// let article = res.content_1;
// WxParse.wxParse('article', 'html', article, this, 5);
// }
// }).catch((err) => {
// console.log(err);
// })
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "案例详情"
}
\ No newline at end of file
... ...
<!--pages/caseDetail/caseDetail.wxml-->
<view class='case_detail_page'>
<view class='case_detail_top'>
<view class='case_detail_banner'>
<swiper bindchange='swiperChange'
indicator-dots="{{indicatorDots}}"
autoplay="{{autoplay}}"
interval="{{interval}}"
duration="{{duration}}"
circular="{{circular}}">
<block wx:for="{{imgUrls}}" wx:key>
<swiper-item>
<image src="{{item.url}}" class="slide-image" width="100%" height="100%" />
</swiper-item>
</block>
</swiper>
<view class='dots_box'>
<view class="dots">
<block wx:for="{{imgUrls}}" wx:key="">
<view class="dot{{index == currentSwiper ? ' active' : ''}}"></view>
</block>
</view>
</view>
</view>
<view class='case_info'>
<view class='case_title'>某政府科技金融中心</view>
<view class='lable_list_box'>
<view class='lable_list'>政府</view>
<view class='lable_list'>工作效率</view>
<view class='lable_list'>业务分析</view>
<view class='lable_list'>快速报表</view>
</view>
</view>
</view>
<view class='case_info_lists'>
<view class='case_info_title'>
<view data-id='0' class="info_title_list {{listStatus == 0 ? ' now' : ''}}" bindtap='toggleFun'>
项目简介
<view class='line'></view>
</view>
<view data-id='1' class="info_title_list {{listStatus == 1 ? ' now' : ''}}" bindtap='toggleFun'>
实施与应用
<view class='line'></view>
</view>
</view>
<view class='info_box'>
<view class='info_list' wx:if="{{listStatus==0}}">
<!-- <import src="/wxParse/wxParse.wxml"/>
<template is="wxParse" data="{{wxParseData:article.nodes}}"/> -->
<image src="../images/jianjie.png" mode='widthFix'></image>
</view>
<view class='info_list' wx:else>
<image src="../images/shishi.png" mode='widthFix'></image>
</view>
</view>
</view>
<!-- 客服 -->
<view class='chat_peo'>
<button open-type="contact" class='contacButton'>
<image src='../images/chat_peo.png'></image>
</button>
</view>
<!-- 返回顶部 -->
<view class='chat_peo return_top' wx:if="{{scrollTop>minscreenHeight}}" bindtap="goTop" >
<image src='../images/dingbu.png'></image>
</view>
</view>
... ...
/* pages/caseDetail/caseDetail.wxss */
/* @import "/wxParse/wxParse.wxss"; */
.case_detail_page {
/* height: 100%; */
background: #F0ECEA;
}
.case_detail_top {
width: 100%;
/* height: 662rpx; */
margin-bottom: 17rpx;
}
.case_detail_banner {
width: 100%;
height: 520rpx;
}
.case_detail_banner swiper {
width: 100%;
height: 466rpx;
}
.case_detail_banner swiper image {
width: 100%;
height: 100%;
}
.dots_box {
width: 100%;
height:54rpx;
background:rgba(1,6,17,1);
position: relative;
}
.dots{
/* width: 156rpx; */
height: 36rpx;
display: flex;
flex-direction: row;
align-items: center;
position: absolute;
left: 320rpx;
top: 50%;
margin-top: -16rpx;
}
/*未选中时的小圆点样式 */
.dot{
width: 16rpx;
height: 16rpx;
border-radius: 50%;
margin-right: 26rpx;
background-color:#CCCCCC;
}
/*选中以后的小圆点样式 */
.active{
width: 16rpx;
height: 16rpx;
border-radius:8rpx;
background-color: #FB7F47;
}
/* 简介 */
.case_info {
width: 100%;
/* height:142rpx; */
background:rgba(240,131,12,1);
box-sizing: border-box;
padding: 30rpx;
}
.case_info .case_title {
font-size: 32rpx;
color: #FFFFFF;
font-weight: bold;
margin-bottom: 19rpx;
}
.lable_list_box {
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
}
.lable_list_box .lable_list {
padding: 6rpx 14rpx;
border:1rpx solid rgba(255,255,255,1);
border-radius:6rpx;
color: #FFFFFF;
font-size: 20rpx;
margin-right: 20rpx;
}
/* 详情 */
.case_info_lists {
margin-top: 17rpx;
width: 100%;
background: #FFFFFF;
}
.case_info_lists .case_info_title {
width: 100%;
height: 109rpx;
border-bottom: 1rpx solid #EBEBEB;
box-sizing: border-box;
padding: 0 222rpx;
display: flex;
justify-content: space-around;
/* align-items: center; */
}
.info_title_list {
font-size: 30rpx;
color: #333333;
position: relative;
height: 100%;
line-height: 109rpx;
}
.info_title_list.now {
color: rgba(240,131,12,1);
}
.info_title_list.now .line {
width:40rpx;
height:6rpx;
background:rgba(240,131,12,1);
position: absolute;
left: 50%;
margin-left: -20rpx;
bottom: 0;
}
.info_box {
width: 100%;
box-sizing: border-box;
padding: 0 30rpx 250rpx;
}
.info_box .info_list {
width: 100%;
}
.info_list image {
width: 100%;
}
... ...
// pages/caseList/caseList.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.setNavigationBarTitle({
title: options.html,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "政府案例"
}
\ No newline at end of file
... ...
<!--pages/caseList/caseList.wxml-->
<view class='case_list_wrap'>
<view class='case_list_box'>
<view class='case_list'>
<view class='case_top'>
<view class='case_title'>某政府科技金融中心</view>
<view class='case_lable_box'>
<view class='case_lable_list'>政府</view>
<view class='case_lable_list'>工作效率</view>
<view class='case_lable_list'>业务分析</view>
<view class='case_lable_list'>快速报表</view>
</view>
</view>
<view class='case_list_content'>
<image src='../images/case_list.png'></image>
</view>
<view class='case_bottom_list'>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
</view>
</view>
<view class='case_list'>
<view class='case_top'>
<view class='case_title'>某政府科技金融中心</view>
<view class='case_lable_box'>
<view class='case_lable_list'>政府</view>
<view class='case_lable_list'>工作效率</view>
<view class='case_lable_list'>业务分析</view>
<view class='case_lable_list'>快速报表</view>
</view>
</view>
<view class='case_list_content'>
<image src='../images/case_list.png'></image>
</view>
<view class='case_bottom_list'>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
</view>
</view>
<view class='case_list'>
<view class='case_top'>
<view class='case_title'>某政府科技金融中心</view>
<view class='case_lable_box'>
<view class='case_lable_list'>政府</view>
<view class='case_lable_list'>工作效率</view>
<view class='case_lable_list'>业务分析</view>
<view class='case_lable_list'>快速报表</view>
</view>
</view>
<view class='case_list_content'>
<image src='../images/case_list.png'></image>
</view>
<view class='case_bottom_list'>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
</view>
</view>
<view class='case_list'>
<view class='case_top'>
<view class='case_title'>某政府科技金融中心</view>
<view class='case_lable_box'>
<view class='case_lable_list'>政府</view>
<view class='case_lable_list'>工作效率</view>
<view class='case_lable_list'>业务分析</view>
<view class='case_lable_list'>快速报表</view>
</view>
</view>
<view class='case_list_content'>
<image src='../images/case_list.png'></image>
</view>
<view class='case_bottom_list'>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
</view>
</view>
<view class='case_list'>
<view class='case_top'>
<view class='case_title'>某政府科技金融中心</view>
<view class='case_lable_box'>
<view class='case_lable_list'>政府</view>
<view class='case_lable_list'>工作效率</view>
<view class='case_lable_list'>业务分析</view>
<view class='case_lable_list'>快速报表</view>
</view>
</view>
<view class='case_list_content'>
<image src='../images/case_list.png'></image>
</view>
<view class='case_bottom_list'>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
<view class='case_bottom_banner'>
<image mode='widthFix' src='../images/case_bottom_list01.png'></image>
</view>
</view>
</view>
</view>
<!-- 客服 -->
<view class='chat_peo'>
<button open-type="contact" class='contacButton'>
<image src='../images/chat_peo.png'></image>
</button>
</view>
<!-- 返回顶部 -->
<view class='chat_peo return_top' >
<image src='../images/dingbu.png'></image>
</view>
</view>
... ...
/* pages/caseList/caseList.wxss */
.case_list_wrap {
width: 100%;
/* height: 100%; */
background: #F0EFED;
}
.case_list_box {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 20rpx 30rpx;
}
.case_list {
background: #fff;
width: 100%;
border-radius: 10rpx;
margin-bottom: 20rpx;
}
.case_top {
width: 100%;
height: 166rpx;
box-sizing: border-box;
padding: 40rpx 24rpx 0;
}
.case_title {
font-size: 32rpx;
color: #000000;
font-weight: bold;
margin-bottom: 19rpx;
}
.case_lable_box {
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
}
.case_lable_list {
padding: 6rpx 14rpx;
border-radius: 6rpx;
border:1px solid rgba(240,131,12,1);
color: rgba(240,131,12,1);
font-size: 20rpx;
margin-right: 20rpx;
}
.case_list_content {
width: 100%;
box-sizing: border-box;
padding: 30rpx 15rpx 0;
height: 465rpx;
}
.case_list_content image {
width: 100%;
height: 100%;
}
.case_bottom_list {
height: 206rpx;
padding: 10rpx 0 50rpx 10rpx;
display: flex;
overflow-x: scroll;
box-sizing: border-box;
}
.case_bottom_banner {
width: 236rpx;
height: 156rpx;
display: flex;
justify-content: center;
align-items: center;
}
.case_bottom_banner image {
width: 236rpx;
}
... ...
... ... @@ -4,51 +4,39 @@ const app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
bindViewTap: function () {
},
onLoad: function () {
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
//首先获取小程序实例,访问app.js中的函数
//调用show函数,传参
//注意:查看上面show函数定义查看参数含义
//第一个参数是当前的页面对象,方便函数setData直接返回数据
//第二个参数是绑定的数据名,传参给setData,详细见上面
//第三个参数是上下滑动的px,因为class="init"定义初始该元素向下偏移了200px,所以这里使其上移200px
//第四个参数是需要修改为的透明度,这里是1,表示从初始的class="init"中定义的透明度0修改到1
app.slideupshow(this, 'slide_up1', 0, 1);
app.sliderightshow(this, 'slide_up2', 0, 1);
},
getUserInfo: function (e) {
},
tapName: function (e) {
wx.navigateTo({
url: '../case/case'
})
}
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
wx.navigateTo({
url: '../case/case'
})
}
},
})
... ...
{
"navigationBarTitleText": "锐网科技案例集锦"
}
\ No newline at end of file
... ...
<!--index.wxml-->
<view class="container">
<view class="userinfo">
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
<view class='imgPolytope'>
<image src='../images/shouye.png'></image>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
<view>1q1111111s</view>
<view class='index_title'>
<view class='title init' animation="{{slide_up1}}">数据分析及可视化</view>
<view class='content contentInit' animation="{{slide_up2}}">大数据探索商业价值的无限可能</view>
</view>
<view class='drop_img' bindtap="tapName">
<image src='../images/drop.png'></image>
</view>
</view>
... ...
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
.container {
width: 100%;
height: 100%;
background:linear-gradient(rgba(249,243,239,1),rgba(237,215,204,1));
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
.imgPolytope {
width: 519rpx;
height: 577rpx;
margin: 190rpx 0 0;
}
.userinfo-nickname {
color: #aaa;
.imgPolytope image {
width: 100%;
height: 100%;
}
.usermotto {
margin-top: 200px;
.index_title .title {
color: #000;
font-size: 46rpx;
margin-bottom: 31rpx;
}
.content {
color: #F0830C;
font-size: 26rpx;
}
.init {
opacity: 0;
transform: translateY(1000px);
}
.contentInit {
opacity: 0;
transform: translateX(1000px);
}
... ...
{
"description": "项目配置文件。",
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
... ... @@ -10,7 +10,7 @@
"compileType": "miniprogram",
"libVersion": "1.6.6",
"appid": "wxd88427f7f68c3da4",
"projectname": "ruiwang",
"projectname": "rw",
"condition": {
"search": {
"current": -1,
... ...
/**
* html2Json 改造来自: https://github.com/Jxck/html2json
*
*
* author: Di (微信小程序开发工程师)
* organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
* 垂直微信小程序开发交流社区
*
* github地址: https://github.com/icindy/wxParse
*
* for: 微信小程序富文本解析
* detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
*/
var __placeImgeUrlHttps = "https";
var __emojisReg = '';
var __emojisBaseSrc = '';
var __emojis = {};
var wxDiscode = require('./wxDiscode.js');
var HTMLParser = require('./htmlparser.js');
// Empty Elements - HTML 5
var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
// Block Elements - HTML 5
var block = makeMap("br,a,code,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
// Inline Elements - HTML 5
var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
// Elements that you can, intentionally, leave open
// (and which close themselves)
var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
// Attributes that have their values filled in disabled="disabled"
var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
// Special Elements (can contain anything)
var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block");
function makeMap(str) {
var obj = {}, items = str.split(",");
for (var i = 0; i < items.length; i++)
obj[items[i]] = true;
return obj;
}
function q(v) {
return '"' + v + '"';
}
function removeDOCTYPE(html) {
return html
.replace(/<\?xml.*\?>\n/, '')
.replace(/<.*!doctype.*\>\n/, '')
.replace(/<.*!DOCTYPE.*\>\n/, '');
}
function trimHtml(html) {
return html
.replace(/\r?\n+/g, '')
.replace(/<!--.*?-->/ig, '')
.replace(/\/\*.*?\*\//ig, '')
.replace(/[ ]+</ig, '<')
}
function html2json(html, bindName) {
//处理字符串
html = removeDOCTYPE(html);
html = trimHtml(html);
html = wxDiscode.strDiscode(html);
//生成node节点
var bufArray = [];
var results = {
node: bindName,
nodes: [],
images:[],
imageUrls:[]
};
var index = 0;
HTMLParser(html, {
start: function (tag, attrs, unary) {
//debug(tag, attrs, unary);
// node for this element
var node = {
node: 'element',
tag: tag,
};
if (bufArray.length === 0) {
node.index = index.toString()
index += 1
} else {
var parent = bufArray[0];
if (parent.nodes === undefined) {
parent.nodes = [];
}
node.index = parent.index + '.' + parent.nodes.length
}
if (block[tag]) {
node.tagType = "block";
} else if (inline[tag]) {
node.tagType = "inline";
} else if (closeSelf[tag]) {
node.tagType = "closeSelf";
}
if (attrs.length !== 0) {
node.attr = attrs.reduce(function (pre, attr) {
var name = attr.name;
var value = attr.value;
if (name == 'class') {
// console.dir(value);
// value = value.join("")
node.classStr = value;
}
// has multi attibutes
// make it array of attribute
if (name == 'style') {
// console.dir(value);
// value = value.join("")
node.styleStr = value;
}
if (value.match(/ /)) {
value = value.split(' ');
}
// if attr already exists
// merge it
if (pre[name]) {
if (Array.isArray(pre[name])) {
// already array, push to last
pre[name].push(value);
} else {
// single value, make it array
pre[name] = [pre[name], value];
}
} else {
// not exist, put it
pre[name] = value;
}
return pre;
}, {});
}
//对img添加额外数据
if (node.tag === 'img') {
node.imgIndex = results.images.length;
var imgUrl = node.attr.src;
if (imgUrl[0] == '') {
imgUrl.splice(0, 1);
}
imgUrl = wxDiscode.urlToHttpUrl(imgUrl, __placeImgeUrlHttps);
node.attr.src = imgUrl;
node.from = bindName;
results.images.push(node);
results.imageUrls.push(imgUrl);
}
// 处理font标签样式属性
if (node.tag === 'font') {
var fontSize = ['x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', '-webkit-xxx-large'];
var styleAttrs = {
'color': 'color',
'face': 'font-family',
'size': 'font-size'
};
if (!node.attr.style) node.attr.style = [];
if (!node.styleStr) node.styleStr = '';
for (var key in styleAttrs) {
if (node.attr[key]) {
var value = key === 'size' ? fontSize[node.attr[key]-1] : node.attr[key];
node.attr.style.push(styleAttrs[key]);
node.attr.style.push(value);
node.styleStr += styleAttrs[key] + ': ' + value + ';';
}
}
}
//临时记录source资源
if(node.tag === 'source'){
results.source = node.attr.src;
}
if (unary) {
// if this tag doesn't have end tag
// like <img src="hoge.png"/>
// add to parents
var parent = bufArray[0] || results;
if (parent.nodes === undefined) {
parent.nodes = [];
}
parent.nodes.push(node);
} else {
bufArray.unshift(node);
}
},
end: function (tag) {
//debug(tag);
// merge into parent tag
var node = bufArray.shift();
if (node.tag !== tag) console.error('invalid state: mismatch end tag');
//当有缓存source资源时于于video补上src资源
if(node.tag === 'video' && results.source){
node.attr.src = results.source;
delete results.source;
}
if (bufArray.length === 0) {
results.nodes.push(node);
} else {
var parent = bufArray[0];
if (parent.nodes === undefined) {
parent.nodes = [];
}
parent.nodes.push(node);
}
},
chars: function (text) {
//debug(text);
var node = {
node: 'text',
text: text,
textArray:transEmojiStr(text)
};
if (bufArray.length === 0) {
node.index = index.toString()
index += 1
results.nodes.push(node);
} else {
var parent = bufArray[0];
if (parent.nodes === undefined) {
parent.nodes = [];
}
node.index = parent.index + '.' + parent.nodes.length
parent.nodes.push(node);
}
},
comment: function (text) {
//debug(text);
// var node = {
// node: 'comment',
// text: text,
// };
// var parent = bufArray[0];
// if (parent.nodes === undefined) {
// parent.nodes = [];
// }
// parent.nodes.push(node);
},
});
return results;
};
function transEmojiStr(str){
// var eReg = new RegExp("["+__reg+' '+"]");
// str = str.replace(/\[([^\[\]]+)\]/g,':$1:')
var emojiObjs = [];
//如果正则表达式为空
if(__emojisReg.length == 0 || !__emojis){
var emojiObj = {}
emojiObj.node = "text";
emojiObj.text = str;
array = [emojiObj];
return array;
}
//这个地方需要调整
str = str.replace(/\[([^\[\]]+)\]/g,':$1:')
var eReg = new RegExp("[:]");
var array = str.split(eReg);
for(var i = 0; i < array.length; i++){
var ele = array[i];
var emojiObj = {};
if(__emojis[ele]){
emojiObj.node = "element";
emojiObj.tag = "emoji";
emojiObj.text = __emojis[ele];
emojiObj.baseSrc= __emojisBaseSrc;
}else{
emojiObj.node = "text";
emojiObj.text = ele;
}
emojiObjs.push(emojiObj);
}
return emojiObjs;
}
function emojisInit(reg='',baseSrc="/wxParse/emojis/",emojis){
__emojisReg = reg;
__emojisBaseSrc=baseSrc;
__emojis=emojis;
}
module.exports = {
html2json: html2json,
emojisInit:emojisInit
};
... ...
/**
*
* htmlParser改造自: https://github.com/blowsie/Pure-JavaScript-HTML5-Parser
*
* author: Di (微信小程序开发工程师)
* organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
* 垂直微信小程序开发交流社区
*
* github地址: https://github.com/icindy/wxParse
*
* for: 微信小程序富文本解析
* detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
*/
// Regular Expressions for parsing tags and attributes
var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/,
attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
// Empty Elements - HTML 5
var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
// Block Elements - HTML 5
var block = makeMap("a,address,code,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
// Inline Elements - HTML 5
var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
// Elements that you can, intentionally, leave open
// (and which close themselves)
var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
// Attributes that have their values filled in disabled="disabled"
var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
// Special Elements (can contain anything)
var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block");
function HTMLParser(html, handler) {
var index, chars, match, stack = [], last = html;
stack.last = function () {
return this[this.length - 1];
};
while (html) {
chars = true;
// Make sure we're not in a script or style element
if (!stack.last() || !special[stack.last()]) {
// Comment
if (html.indexOf("<!--") == 0) {
index = html.indexOf("-->");
if (index >= 0) {
if (handler.comment)
handler.comment(html.substring(4, index));
html = html.substring(index + 3);
chars = false;
}
// end tag
} else if (html.indexOf("</") == 0) {
match = html.match(endTag);
if (match) {
html = html.substring(match[0].length);
match[0].replace(endTag, parseEndTag);
chars = false;
}
// start tag
} else if (html.indexOf("<") == 0) {
match = html.match(startTag);
if (match) {
html = html.substring(match[0].length);
match[0].replace(startTag, parseStartTag);
chars = false;
}
}
if (chars) {
index = html.indexOf("<");
var text = ''
while (index === 0) {
text += "<";
html = html.substring(1);
index = html.indexOf("<");
}
text += index < 0 ? html : html.substring(0, index);
html = index < 0 ? "" : html.substring(index);
if (handler.chars)
handler.chars(text);
}
} else {
html = html.replace(new RegExp("([\\s\\S]*?)<\/" + stack.last() + "[^>]*>"), function (all, text) {
text = text.replace(/<!--([\s\S]*?)-->|<!\[CDATA\[([\s\S]*?)]]>/g, "$1$2");
if (handler.chars)
handler.chars(text);
return "";
});
parseEndTag("", stack.last());
}
if (html == last)
throw "Parse Error: " + html;
last = html;
}
// Clean up any remaining tags
parseEndTag();
function parseStartTag(tag, tagName, rest, unary) {
tagName = tagName.toLowerCase();
if (block[tagName]) {
while (stack.last() && inline[stack.last()]) {
parseEndTag("", stack.last());
}
}
if (closeSelf[tagName] && stack.last() == tagName) {
parseEndTag("", tagName);
}
unary = empty[tagName] || !!unary;
if (!unary)
stack.push(tagName);
if (handler.start) {
var attrs = [];
rest.replace(attr, function (match, name) {
var value = arguments[2] ? arguments[2] :
arguments[3] ? arguments[3] :
arguments[4] ? arguments[4] :
fillAttrs[name] ? name : "";
attrs.push({
name: name,
value: value,
escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //"
});
});
if (handler.start) {
handler.start(tagName, attrs, unary);
}
}
}
function parseEndTag(tag, tagName) {
// If no tag name is provided, clean shop
if (!tagName)
var pos = 0;
// Find the closest opened tag of the same type
else {
tagName = tagName.toLowerCase();
for (var pos = stack.length - 1; pos >= 0; pos--)
if (stack[pos] == tagName)
break;
}
if (pos >= 0) {
// Close all the open elements, up the stack
for (var i = stack.length - 1; i >= pos; i--)
if (handler.end)
handler.end(stack[i]);
// Remove the open elements from the stack
stack.length = pos;
}
}
};
function makeMap(str) {
var obj = {}, items = str.split(",");
for (var i = 0; i < items.length; i++)
obj[items[i]] = true;
return obj;
}
module.exports = HTMLParser;
... ...