作者 李洪娟

口袋宇宙

正在显示 64 个修改的文件 包含 4790 行增加0 行删除

要显示太多修改。

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

App({
onLaunch: function () {
},
post: function (url, data, headerParams) {
/**
* 自定义post函数,返回Promise
* +-------------------
* @param {String} url 接口网址
* @param {arrayObject} data 要传的数组对象 like: {name: 'name', age: 32}
* +-------------------
* @return {Promise} promise 返回promise供后续操作
*/
// wx.showLoading({
// title: '加载中',
// })
wx.showNavigationBarLoading()
// wx.showLoading({
// title: '加载中',
// })
var promise = new Promise((resolve, reject) => {
//init
let that = this;
let postData = data;
//let baseUrl = 'http://192.168.1.21/api/';
let baseUrl = 'https://glocalize-asia.com/api';
// let baseUrl = 'http://192.168.1.15/public';
// postData.signature = that.makeSign(postData);
//网络请求
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 == '20000') {
resolve(res.data.data);
} else if (res.data.code == '40001') {//返回错误提示信息
wx.showModal({
title: '提示',
content: '登录已过期请重新登录!',
showCancel: false,
success: function (res) {
if (res.confirm) {
wx.removeStorageSync('token');
wx.navigateTo({
// url: '/pages/startRecord/startRecord',
})
}
}
})
} else if (res.data.code == '40002') {
console.log(res)
// wx.showModal({
// title: '提示',
// // content: res.data.msg,
// showCancel: false,
// success: function (res) { }
// })
} else if (res.data.code == '40003') {
// 初始化用户信息判断
let usetrInfoType = {
hasUserInfo: false
}
resolve(usetrInfoType);
// wx.showModal({
// title: '提示',
// content: res.data.msg,
// showCancel: false
// })
} else {
console.log(res)
wx.showToast({
title: res.data.msg,
icon:'none'
})
// wx.showModal({
// title: '提示',
// // content: res.data.msg,
// showCancel: false
// })
reject(res.data)
}
},
fail: function (e) {
reject('网络出错');
},
complete:function(){
wx.hideNavigationBarLoading()
}
})
});
return promise;
},
objToArry(obc){
let tempArry = []
for(let obj of obc){
tempArry.push(obj.image)
}
return tempArry;
},
// upload(filetype, file) {
// var promise = new Promise((resolve, reject) => {
// wx.showNavigationBarLoading()
// wx.showLoading({
// title: '上传中',
// })
// let url = 'http://anleguo.w.bronet.cn/portal/common/upload';
// let head = {
// 'XX-Token': wx.getStorageSync('token'),
// 'XX-Device-Type': ''
// }
// let typename = {
// filetype: filetype
// }
// wx.uploadFile({
// url: url, //仅为示例,非真实的接口地址
// filePath: file,
// name: 'file',
// header: {},
// formData: typename,
// success: function (res) {
// console.log('上传文件后', res)
// let temdata = JSON.parse(res.data);
// let urlobj = {
// url: temdata.data.preview_url
// //url: temdata.data.filepath
// }
// resolve(urlobj);
// wx.hideNavigationBarLoading();
// wx.hideLoading();
// },
// fail: function (res) {
// reject('网络出错');
// wx.hideNavigationBarLoading()
// wx.hideLoading()
// },
// complete: () => {
// wx.hideNavigationBarLoading()
// wx.hideLoading()
// },
// })
// });
// return promise;
// },
/**
* 自定义上传文件,返回文件路径
* +-------------------
* @filetype{String} 文件类型.image,video,audio,file
* @filePath String 要传的文件路径
* +-------------------
* @return url 返回文件路径
*/
upload(filetype, file) {
var promise = new Promise((resolve, reject) => {
wx.showNavigationBarLoading()
wx.showLoading({
title: '上传中',
})
//let url = 'http://anleguo.w.bronet.cn/portal/common/upload';
let url ='https://glocalize-asia.com/api/home/Upload/upload'
let head = {
'XX-Token': wx.getStorageSync('token'),
'XX-Device-Type': ''
}
let typename = {
filetype: filetype
}
wx.uploadFile({
url: url, //仅为示例,非真实的接口地址
filePath: file,
name: 'file',
header: {},
formData: typename,
success: function (res) {
console.log('上传文件后', res)
let temdata = JSON.parse(res.data);
let urlobj = {
url: temdata.data
}
resolve(urlobj);
wx.hideNavigationBarLoading();
wx.hideLoading();
},
fail: function (res) {
reject('网络出错');
wx.hideNavigationBarLoading()
wx.hideLoading()
},
complete: () => {
wx.hideNavigationBarLoading()
wx.hideLoading()
},
})
});
return promise;
},
formCollect(id) {
let url = '/sign/formid'
let params = {
formid: id,
openid: wx.getStorageSync('openId')
}
this.post(url, params).then((res) => {
console.log(res)
}).catch((errMsg) => {
})
},
nowDate() {
let date = new Date();
let month = date.getMonth() + 1;
let day = date.getDate();
return date.getFullYear() + '年' + (month > 9 ? month : ('0' + month)) + '月' + (day > 9 ? day : ('0' + day)) + '日';
},
initDate(a) {
let date1 = new Date();
let time1 = date1.getFullYear() + "年" + (date1.getMonth() + 1) + "月" + date1.getDate() + '日';
let date2 = new Date(date1);
date2.setDate(date1.getDate() + a);
let time2 = date2.getFullYear() + "年" + (date2.getMonth() + 1) + "月" + date2.getDate() + '日';
return time2;
},
// 数组移除指定元素
arryRemove(arr, item) {
return arr.filter(function (ele) {
return ele != item;
})
},
strTime(strtime) {
let str = 'bronet' + strtime + 'beijing'
return md5(md5(str))
},
//数组变字符串,中间用,隔开
array_to_string(arr) {
let str = '';
for (let i = 0; i < arr.length; i++) {
if (i == (arr.length - 1)) {
str += arr[i]
} else {
str += arr[i] + ','
}
}
return str;
},
globalData: {
userInfo: null,
baseUrl: 'http://beijing.w.bronet.cn',
baseImgUrl:''
}
})
... ...
{
"pages": [
"pages/index/index",
"pages/questionsurvey/questionsurvey",
"pages/choseimg/choseimg",
"pages/searchlist/searchlist",
"pages/preview/preview",
"pages/comment/comment",
"pages/teachplan/teachplanlistdetailtwo/teachplanlistdetailtwo",
"pages/teachplan/teachplanlistdetailone/teachplanlistdetailnone",
"pages/pocketlesson/pocketlesson",
"pages/mine/mine",
"pages/teachplan/teachplanlistdetail/teachplanlistdetail",
"pages/teachplan/teachplanlist/teachplanlist",
"pages/searchpage/searchpage",
"pages/kind/kind",
"pages/logs/logs",
"pages/my_collect/my_collect",
"pages/explain/explain",
"pages/pay_record/pay_record",
"pages/member_center/member_center",
"pages/aboutme/aboutme",
"pages/download/download",
"pages/sureload/sureload",
"pages/imgscale/imgscale",
"pages/zujian/zujian"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"plugins": {
"tencentvideo": {
"version": "1.2.5",
"provider": "wxa75efa648b60994b"
}
},
"tabBar": {
"selectedColor": "#155392",
"list": [
{
"pagePath": "pages/pocketlesson/pocketlesson",
"text": "首页",
"selectedColor": "#155392",
"iconPath": "img/newdsfasdfg@2x.png",
"selectedIconPath": "img/newgw3eqkjpp@2x.png"
},
{
"pagePath": "pages/kind/kind",
"text": "分类",
"selectedColor": "#155392",
"iconPath": "img/newkind.png",
"selectedIconPath": "img/newhjrertf@2x.png"
},
{
"pagePath": "pages/mine/mine",
"text": "我的",
"selectedColor": "#FC7E65",
"iconPath": "img/newperson.png",
"selectedIconPath": "img/newsdfgfhg@2x.png"
}
]
},
"sitemapLocation": "sitemap.json"
}
\ No newline at end of file
... ...
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
.itemprice{
color:#FF8080;
font-weight: bold;
}
@font-face {font-family: "iconfont";
src: url('//at.alicdn.com/t/font_999857_hzvzavs2sf5.eot?t=1547188697585'); /* IE9 */
src: url('//at.alicdn.com/t/font_999857_hzvzavs2sf5.eot?t=1547188697585#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAS0AAsAAAAACVAAAARlAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDSAqFHIRhATYCJAMYCw4ABCAFhG0Hfhs9CBEVpDOQ/UiwcYuL9bTVIqco5U3w/P//+f5ce5+c8IqlTgUkKchUSftcQl9C+IRCf69/dyQANjf7sY2KUCzJefC/PCMtYYVPU8YfHEv9tAbLA3qXrqDnF3yw72VatA5wAxlPUKdhXtMO0k348WoI4KIkFtKuQ7d+ODDwtgkgkyeMG4GjpsUYIAsOhUkcaSBrseFQP6onwJr05+UjdcQBCpvG27PX2PajafWGNz10MBlkcIyAt50ZUI4DDViAAbKItM5F51ELjcv6CwZdAA8OFMYb3rjfZL6x3vRIJmtCzyl4/H95YGBD0CgQE0g9AtstZoM3hGoMS+YGl5JlQo1AZkGNhqwHmlAAmBuusQMvQarj4SwigqD4w/YrluvJyM+bt+LSsVME75bfSvDcvYfuFTfuXCh2+LSEdpw4suLQsW0ET5bfGYbIQuinqO90FJNKDnzatnO3rrlXPH5wIVR4+LyE9py4Mu+nRlcrH29y3fVT+EWYSMTr9cdi/lD0VdS1wHcnJtGoLxzuR5WviPX0blpxYnvAZFfZHXtGo7PGbg5tWZEzZlMwe/TGnxxV3qjIG/VFpV9T5USc6Q32C4c3Dl0e/avz43/8W32Z7I3Zsjl3c1SCOcNumTml1c6fipWaMqJHqcKEb51/4uNimX+MKypfNO6PzGLXBzZO9+d7y/Sq3b5gU7HdG4t1KKhduleBN93feOD2KR/zuVzRvOeZxR8P6L/OHy8s2SM4tNmJxfdK5nx9Oozd8TqR0tevl47UsbqVulGquyVj9975cX6Hlj4rvsu+O4y1Sna/0b2URdNa5qtXyTDQSe+Px/drsKDT+8szdFpUveur11sLyg2p+/Kl+vH8+R8jkeJT6ke+nLVLfL5x2V+y544bP4+L5+LsY0kWsx2c3al7q8dnT8vgQGCwdFUj2wwZErLS1MESCMjg0yRrYO/ZnQ4+3N1FRo2iS/rJ8l8/fxbnyDgpXUaN6iJec9BAc/xezvbP7sciAJK/67tqGYCeoxKQvKkf6FbS5iL1TCsAvUf99yv9DueqNLk4LK3Z/w63AUB86MAEPMmbBsu4/4OMybwfhzdxxLAFns40zM5hHQKY9NuEE4td/hT8Ls5Mft9KnjM5HwQHOSUo7JQAjYPySANrgQ039cDEQUtwUY2Ox7vJYiYaMZxAVb5lIKRzBhSp3AFNOk+RBvY3sJHLZzBJFw0ufJJ1RjeeikKPtoKFYg3lBlTxaAKDPrLCJ1rfF1IVpJQviqMAxEHUTOQ4omyxj5ttomrACA+Qseth3zNMwi1WGjSqUxqGhnqmoOJh96CtYKFYA+UGUMWjiWfro/X9T7S+L2Sgo8X8RXE0PxATEE1A5tJxUserLHazTVA1YpMRHoAMZuz9KAMTvarFSgOaBeEpJeSTzFRpcLx8uIEcpQfvfKYo0WKITUyx4xzvi9HaSHUKhAfEF8feeU6UCv53q34E8TLo3ti3hUgT3UpVdmrdqAQrNI/2GGl2OwAAAA==') format('woff2'),
url('//at.alicdn.com/t/font_999857_hzvzavs2sf5.woff?t=1547188697585') format('woff'),
url('//at.alicdn.com/t/font_999857_hzvzavs2sf5.ttf?t=1547188697585') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
url('//at.alicdn.com/t/font_999857_hzvzavs2sf5.svg?t=1547188697585#iconfont') format('svg'); /* iOS 4.1- */
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-huangguan:before {
content: "\e612";
}
.icon-zan1:before {
content: "\e64e";
}
.icon-sousuo:before {
content: "\e62c";
}
.icon-tiaozhuanqianwangyoujiantouxiangyouxiayibuxianxing:before {
content: "\e600";
}
.icon-xin:before {
content: "\e60b";
}
.nodata{
color:#999;
font-size: 32rpx;
text-align: center;
padding: 32rpx;
}
\ No newline at end of file
... ...
/**
* we-cropper v1.2.0
* (c) 2018 dlhandsome
* @license MIT
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.WeCropper = factory());
}(this, (function () { 'use strict';
var device = void 0;
var TOUCH_STATE = ['touchstarted', 'touchmoved', 'touchended'];
function isFunction (obj) {
return typeof obj === 'function'
}
function firstLetterUpper (str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
function setTouchState (instance) {
var arg = [], len = arguments.length - 1;
while ( len-- > 0 ) arg[ len ] = arguments[ len + 1 ];
TOUCH_STATE.forEach(function (key, i) {
if (arg[i] !== undefined) {
instance[key] = arg[i];
}
});
}
function validator (instance, o) {
Object.defineProperties(instance, o);
}
function getDevice () {
if (!device) {
device = wx.getSystemInfoSync();
}
return device
}
var tmp = {};
var DEFAULT = {
id: {
default: 'cropper',
get: function get () {
return tmp.id
},
set: function set (value) {
if (typeof (value) !== 'string') {
console.error(("id:" + value + " is invalid"));
}
tmp.id = value;
}
},
width: {
default: 750,
get: function get () {
return tmp.width
},
set: function set (value) {
if (typeof (value) !== 'number') {
console.error(("width:" + value + " is invalid"));
}
tmp.width = value;
}
},
height: {
default: 750,
get: function get () {
return tmp.height
},
set: function set (value) {
if (typeof (value) !== 'number') {
console.error(("height:" + value + " is invalid"));
}
tmp.height = value;
}
},
scale: {
default: 2.5,
get: function get () {
return tmp.scale
},
set: function set (value) {
if (typeof (value) !== 'number') {
console.error(("scale:" + value + " is invalid"));
}
tmp.scale = value;
}
},
zoom: {
default: 5,
get: function get () {
return tmp.zoom
},
set: function set (value) {
if (typeof (value) !== 'number') {
console.error(("zoom:" + value + " is invalid"));
} else if (value < 0 || value > 10) {
console.error("zoom should be ranged in 0 ~ 10");
}
tmp.zoom = value;
}
},
src: {
default: 'cropper',
get: function get () {
return tmp.src
},
set: function set (value) {
if (typeof (value) !== 'string') {
console.error(("id:" + value + " is invalid"));
}
tmp.src = value;
}
},
cut: {
default: {},
get: function get () {
return tmp.cut
},
set: function set (value) {
if (typeof (value) !== 'object') {
console.error(("id:" + value + " is invalid"));
}
tmp.cut = value;
}
},
onReady: {
default: null,
get: function get () {
return tmp.ready
},
set: function set (value) {
tmp.ready = value;
}
},
onBeforeImageLoad: {
default: null,
get: function get () {
return tmp.beforeImageLoad
},
set: function set (value) {
tmp.beforeImageLoad = value;
}
},
onImageLoad: {
default: null,
get: function get () {
return tmp.imageLoad
},
set: function set (value) {
tmp.imageLoad = value;
}
},
onBeforeDraw: {
default: null,
get: function get () {
return tmp.beforeDraw
},
set: function set (value) {
tmp.beforeDraw = value;
}
}
};
function prepare () {
var self = this;
var ref = getDevice();
var windowWidth = ref.windowWidth;
self.attachPage = function () {
var pages = getCurrentPages();
// 获取到当前page上下文
var pageContext = pages[pages.length - 1];
// 把this依附在Page上下文的wecropper属性上,便于在page钩子函数中访问
pageContext.wecropper = self;
};
self.createCtx = function () {
var id = self.id;
if (id) {
self.ctx = wx.createCanvasContext(id);
} else {
console.error("constructor: create canvas context failed, 'id' must be valuable");
}
};
self.deviceRadio = windowWidth / 750;
}
function observer () {
var self = this;
var EVENT_TYPE = ['ready', 'beforeImageLoad', 'beforeDraw', 'imageLoad'];
self.on = function (event, fn) {
if (EVENT_TYPE.indexOf(event) > -1) {
if (typeof (fn) === 'function') {
event === 'ready'
? fn(self)
: self[("on" + (firstLetterUpper(event)))] = fn;
}
} else {
console.error(("event: " + event + " is invalid"));
}
return self
};
}
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var base64 = createCommonjsModule(function (module, exports) {
/*! http://mths.be/base64 v0.1.0 by @mathias | MIT license */
(function(root) {
// Detect free variables `exports`.
var freeExports = 'object' == 'object' && exports;
// Detect free variable `module`.
var freeModule = 'object' == 'object' && module &&
module.exports == freeExports && module;
// Detect free variable `global`, from Node.js or Browserified code, and use
// it as `root`.
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
root = freeGlobal;
}
/*--------------------------------------------------------------------------*/
var InvalidCharacterError = function(message) {
this.message = message;
};
InvalidCharacterError.prototype = new Error;
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
var error = function(message) {
// Note: the error messages used throughout this file match those used by
// the native `atob`/`btoa` implementation in Chromium.
throw new InvalidCharacterError(message);
};
var TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// http://whatwg.org/html/common-microsyntaxes.html#space-character
var REGEX_SPACE_CHARACTERS = /[\t\n\f\r ]/g;
// `decode` is designed to be fully compatible with `atob` as described in the
// HTML Standard. http://whatwg.org/html/webappapis.html#dom-windowbase64-atob
// The optimized base64-decoding algorithm used is based on @atk’s excellent
// implementation. https://gist.github.com/atk/1020396
var decode = function(input) {
input = String(input)
.replace(REGEX_SPACE_CHARACTERS, '');
var length = input.length;
if (length % 4 == 0) {
input = input.replace(/==?$/, '');
length = input.length;
}
if (
length % 4 == 1 ||
// http://whatwg.org/C#alphanumeric-ascii-characters
/[^+a-zA-Z0-9/]/.test(input)
) {
error(
'Invalid character: the string to be decoded is not correctly encoded.'
);
}
var bitCounter = 0;
var bitStorage;
var buffer;
var output = '';
var position = -1;
while (++position < length) {
buffer = TABLE.indexOf(input.charAt(position));
bitStorage = bitCounter % 4 ? bitStorage * 64 + buffer : buffer;
// Unless this is the first of a group of 4 characters…
if (bitCounter++ % 4) {
// …convert the first 8 bits to a single ASCII character.
output += String.fromCharCode(
0xFF & bitStorage >> (-2 * bitCounter & 6)
);
}
}
return output;
};
// `encode` is designed to be fully compatible with `btoa` as described in the
// HTML Standard: http://whatwg.org/html/webappapis.html#dom-windowbase64-btoa
var encode = function(input) {
input = String(input);
if (/[^\0-\xFF]/.test(input)) {
// Note: no need to special-case astral symbols here, as surrogates are
// matched, and the input is supposed to only contain ASCII anyway.
error(
'The string to be encoded contains characters outside of the ' +
'Latin1 range.'
);
}
var padding = input.length % 3;
var output = '';
var position = -1;
var a;
var b;
var c;
var buffer;
// Make sure any padding is handled outside of the loop.
var length = input.length - padding;
while (++position < length) {
// Read three bytes, i.e. 24 bits.
a = input.charCodeAt(position) << 16;
b = input.charCodeAt(++position) << 8;
c = input.charCodeAt(++position);
buffer = a + b + c;
// Turn the 24 bits into four chunks of 6 bits each, and append the
// matching character for each of them to the output.
output += (
TABLE.charAt(buffer >> 18 & 0x3F) +
TABLE.charAt(buffer >> 12 & 0x3F) +
TABLE.charAt(buffer >> 6 & 0x3F) +
TABLE.charAt(buffer & 0x3F)
);
}
if (padding == 2) {
a = input.charCodeAt(position) << 8;
b = input.charCodeAt(++position);
buffer = a + b;
output += (
TABLE.charAt(buffer >> 10) +
TABLE.charAt((buffer >> 4) & 0x3F) +
TABLE.charAt((buffer << 2) & 0x3F) +
'='
);
} else if (padding == 1) {
buffer = input.charCodeAt(position);
output += (
TABLE.charAt(buffer >> 2) +
TABLE.charAt((buffer << 4) & 0x3F) +
'=='
);
}
return output;
};
var base64 = {
'encode': encode,
'decode': decode,
'version': '0.1.0'
};
// Some AMD build optimizers, like r.js, check for specific condition patterns
// like the following:
if (
typeof undefined == 'function' &&
typeof undefined.amd == 'object' &&
undefined.amd
) {
undefined(function() {
return base64;
});
} else if (freeExports && !freeExports.nodeType) {
if (freeModule) { // in Node.js or RingoJS v0.8.0+
freeModule.exports = base64;
} else { // in Narwhal or RingoJS v0.7.0-
for (var key in base64) {
base64.hasOwnProperty(key) && (freeExports[key] = base64[key]);
}
}
} else { // in Rhino or a web browser
root.base64 = base64;
}
}(commonjsGlobal));
});
function makeURI (strData, type) {
return 'data:' + type + ';base64,' + strData
}
function fixType (type) {
type = type.toLowerCase().replace(/jpg/i, 'jpeg');
var r = type.match(/png|jpeg|bmp|gif/)[0];
return 'image/' + r
}
function encodeData (data) {
var str = '';
if (typeof data === 'string') {
str = data;
} else {
for (var i = 0; i < data.length; i++) {
str += String.fromCharCode(data[i]);
}
}
return base64.encode(str)
}
/**
* 获取图像区域隐含的像素数据
* @param canvasId canvas标识
* @param x 将要被提取的图像数据矩形区域的左上角 x 坐标
* @param y 将要被提取的图像数据矩形区域的左上角 y 坐标
* @param width 将要被提取的图像数据矩形区域的宽度
* @param height 将要被提取的图像数据矩形区域的高度
* @param done 完成回调
*/
function getImageData (canvasId, x, y, width, height, done) {
wx.canvasGetImageData({
canvasId: canvasId,
x: x,
y: y,
width: width,
height: height,
success: function success (res) {
done(res);
},
fail: function fail (res) {
done(null);
console.error('canvasGetImageData error: ' + res);
}
});
}
/**
* 生成bmp格式图片
* 按照规则生成图片响应头和响应体
* @param oData 用来描述 canvas 区域隐含的像素数据 { data, width, height } = oData
* @returns {*} base64字符串
*/
function genBitmapImage (oData) {
//
// BITMAPFILEHEADER: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183374(v=vs.85).aspx
// BITMAPINFOHEADER: http://msdn.microsoft.com/en-us/library/dd183376.aspx
//
var biWidth = oData.width;
var biHeight = oData.height;
var biSizeImage = biWidth * biHeight * 3;
var bfSize = biSizeImage + 54; // total header size = 54 bytes
//
// typedef struct tagBITMAPFILEHEADER {
// WORD bfType;
// DWORD bfSize;
// WORD bfReserved1;
// WORD bfReserved2;
// DWORD bfOffBits;
// } BITMAPFILEHEADER;
//
var BITMAPFILEHEADER = [
// WORD bfType -- The file type signature; must be "BM"
0x42, 0x4D,
// DWORD bfSize -- The size, in bytes, of the bitmap file
bfSize & 0xff, bfSize >> 8 & 0xff, bfSize >> 16 & 0xff, bfSize >> 24 & 0xff,
// WORD bfReserved1 -- Reserved; must be zero
0, 0,
// WORD bfReserved2 -- Reserved; must be zero
0, 0,
// DWORD bfOffBits -- The offset, in bytes, from the beginning of the BITMAPFILEHEADER structure to the bitmap bits.
54, 0, 0, 0
];
//
// typedef struct tagBITMAPINFOHEADER {
// DWORD biSize;
// LONG biWidth;
// LONG biHeight;
// WORD biPlanes;
// WORD biBitCount;
// DWORD biCompression;
// DWORD biSizeImage;
// LONG biXPelsPerMeter;
// LONG biYPelsPerMeter;
// DWORD biClrUsed;
// DWORD biClrImportant;
// } BITMAPINFOHEADER, *PBITMAPINFOHEADER;
//
var BITMAPINFOHEADER = [
// DWORD biSize -- The number of bytes required by the structure
40, 0, 0, 0,
// LONG biWidth -- The width of the bitmap, in pixels
biWidth & 0xff, biWidth >> 8 & 0xff, biWidth >> 16 & 0xff, biWidth >> 24 & 0xff,
// LONG biHeight -- The height of the bitmap, in pixels
biHeight & 0xff, biHeight >> 8 & 0xff, biHeight >> 16 & 0xff, biHeight >> 24 & 0xff,
// WORD biPlanes -- The number of planes for the target device. This value must be set to 1
1, 0,
// WORD biBitCount -- The number of bits-per-pixel, 24 bits-per-pixel -- the bitmap
// has a maximum of 2^24 colors (16777216, Truecolor)
24, 0,
// DWORD biCompression -- The type of compression, BI_RGB (code 0) -- uncompressed
0, 0, 0, 0,
// DWORD biSizeImage -- The size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps
biSizeImage & 0xff, biSizeImage >> 8 & 0xff, biSizeImage >> 16 & 0xff, biSizeImage >> 24 & 0xff,
// LONG biXPelsPerMeter, unused
0, 0, 0, 0,
// LONG biYPelsPerMeter, unused
0, 0, 0, 0,
// DWORD biClrUsed, the number of color indexes of palette, unused
0, 0, 0, 0,
// DWORD biClrImportant, unused
0, 0, 0, 0
];
var iPadding = (4 - ((biWidth * 3) % 4)) % 4;
var aImgData = oData.data;
var strPixelData = '';
var biWidth4 = biWidth << 2;
var y = biHeight;
var fromCharCode = String.fromCharCode;
do {
var iOffsetY = biWidth4 * (y - 1);
var strPixelRow = '';
for (var x = 0; x < biWidth; x++) {
var iOffsetX = x << 2;
strPixelRow += fromCharCode(aImgData[iOffsetY + iOffsetX + 2]) +
fromCharCode(aImgData[iOffsetY + iOffsetX + 1]) +
fromCharCode(aImgData[iOffsetY + iOffsetX]);
}
for (var c = 0; c < iPadding; c++) {
strPixelRow += String.fromCharCode(0);
}
strPixelData += strPixelRow;
} while (--y)
var strEncoded = encodeData(BITMAPFILEHEADER.concat(BITMAPINFOHEADER)) + encodeData(strPixelData);
return strEncoded
}
/**
* 转换为图片base64
* @param canvasId canvas标识
* @param x 将要被提取的图像数据矩形区域的左上角 x 坐标
* @param y 将要被提取的图像数据矩形区域的左上角 y 坐标
* @param width 将要被提取的图像数据矩形区域的宽度
* @param height 将要被提取的图像数据矩形区域的高度
* @param type 转换图片类型
* @param done 完成回调
*/
function convertToImage (canvasId, x, y, width, height, type, done) {
if ( done === void 0 ) done = function () {};
if (type === undefined) { type = 'png'; }
type = fixType(type);
if (/bmp/.test(type)) {
getImageData(canvasId, x, y, width, height, function (data) {
var strData = genBitmapImage(data);
isFunction(done) && done(makeURI(strData, 'image/' + type));
});
} else {
console.error('暂不支持生成\'' + type + '\'类型的base64图片');
}
}
var CanvasToBase64 = {
convertToImage: convertToImage,
// convertToPNG: function (width, height, done) {
// return convertToImage(width, height, 'png', done)
// },
// convertToJPEG: function (width, height, done) {
// return convertToImage(width, height, 'jpeg', done)
// },
// convertToGIF: function (width, height, done) {
// return convertToImage(width, height, 'gif', done)
// },
convertToBMP: function (ref, done) {
if ( ref === void 0 ) ref = {};
var canvasId = ref.canvasId;
var x = ref.x;
var y = ref.y;
var width = ref.width;
var height = ref.height;
if ( done === void 0 ) done = function () {};
return convertToImage(canvasId, x, y, width, height, 'bmp', done)
}
};
function methods () {
var self = this;
var id = self.id;
var deviceRadio = self.deviceRadio;
var boundWidth = self.width; // 裁剪框默认宽度,即整个画布宽度
var boundHeight = self.height; // 裁剪框默认高度,即整个画布高度
var ref = self.cut;
var x = ref.x; if ( x === void 0 ) x = 0;
var y = ref.y; if ( y === void 0 ) y = 0;
var width = ref.width; if ( width === void 0 ) width = boundWidth;
var height = ref.height; if ( height === void 0 ) height = boundHeight;
self.updateCanvas = function () {
if (self.croperTarget) {
// 画布绘制图片
self.ctx.drawImage(self.croperTarget, self.imgLeft, self.imgTop, self.scaleWidth, self.scaleHeight);
}
isFunction(self.onBeforeDraw) && self.onBeforeDraw(self.ctx, self);
self.setBoundStyle(); // 设置边界样式
self.ctx.draw();
return self
};
self.pushOrign = function (src) {
self.src = src;
isFunction(self.onBeforeImageLoad) && self.onBeforeImageLoad(self.ctx, self);
wx.getImageInfo({
src: src,
success: function success (res) {
var innerAspectRadio = res.width / res.height;
self.croperTarget = res.path;
if (innerAspectRadio < width / height) {
self.rectX = x;
self.baseWidth = width;
self.baseHeight = width / innerAspectRadio;
self.rectY = y - Math.abs((height - self.baseHeight) / 2);
} else {
self.rectY = y;
self.baseWidth = height * innerAspectRadio;
self.baseHeight = height;
self.rectX = x - Math.abs((width - self.baseWidth) / 2);
}
self.imgLeft = self.rectX;
self.imgTop = self.rectY;
self.scaleWidth = self.baseWidth;
self.scaleHeight = self.baseHeight;
self.updateCanvas();
isFunction(self.onImageLoad) && self.onImageLoad(self.ctx, self);
}
});
self.update();
return self
};
self.getCropperBase64 = function (done) {
if ( done === void 0 ) done = function () {};
CanvasToBase64.convertToBMP({
canvasId: id,
x: x,
y: y,
width: width,
height: height
}, done);
};
self.getCropperImage = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var ARG_TYPE = toString.call(args[0]);
var fn = args[args.length - 1];
switch (ARG_TYPE) {
case '[object Object]':
var ref = args[0];
var quality = ref.quality; if ( quality === void 0 ) quality = 10;
if (typeof (quality) !== 'number') {
console.error(("quality:" + quality + " is invalid"));
} else if (quality < 0 || quality > 10) {
console.error("quality should be ranged in 0 ~ 10");
}
wx.canvasToTempFilePath({
canvasId: id,
x: x,
y: y,
width: width,
height: height,
destWidth: width * quality / (deviceRadio * 10),
destHeight: height * quality / (deviceRadio * 10),
success: function success (res) {
isFunction(fn) && fn.call(self, res.tempFilePath);
},
fail: function fail (res) {
isFunction(fn) && fn.call(self, null);
}
}); break
case '[object Function]':
wx.canvasToTempFilePath({
canvasId: id,
x: x,
y: y,
width: width,
height: height,
destWidth: width / deviceRadio,
destHeight: height / deviceRadio,
success: function success (res) {
isFunction(fn) && fn.call(self, res.tempFilePath);
},
fail: function fail (res) {
isFunction(fn) && fn.call(self, null);
}
}); break
}
return self
};
}
/**
* 获取最新缩放值
* @param oldScale 上一次触摸结束后的缩放值
* @param oldDistance 上一次触摸结束后的双指距离
* @param zoom 缩放系数
* @param touch0 第一指touch对象
* @param touch1 第二指touch对象
* @returns {*}
*/
var getNewScale = function (oldScale, oldDistance, zoom, touch0, touch1) {
var xMove, yMove, newDistance;
// 计算二指最新距离
xMove = Math.round(touch1.x - touch0.x);
yMove = Math.round(touch1.y - touch0.y);
newDistance = Math.round(Math.sqrt(xMove * xMove + yMove * yMove));
return oldScale + 0.001 * zoom * (newDistance - oldDistance)
};
function update () {
var self = this;
if (!self.src) { return }
self.__oneTouchStart = function (touch) {
self.touchX0 = Math.round(touch.x);
self.touchY0 = Math.round(touch.y);
};
self.__oneTouchMove = function (touch) {
var xMove, yMove;
// 计算单指移动的距离
if (self.touchended) {
return self.updateCanvas()
}
xMove = Math.round(touch.x - self.touchX0);
yMove = Math.round(touch.y - self.touchY0);
var imgLeft = Math.round(self.rectX + xMove);
var imgTop = Math.round(self.rectY + yMove);
self.outsideBound(imgLeft, imgTop);
self.updateCanvas();
};
self.__twoTouchStart = function (touch0, touch1) {
var xMove, yMove, oldDistance;
self.touchX1 = Math.round(self.rectX + self.scaleWidth / 2);
self.touchY1 = Math.round(self.rectY + self.scaleHeight / 2);
// 计算两指距离
xMove = Math.round(touch1.x - touch0.x);
yMove = Math.round(touch1.y - touch0.y);
oldDistance = Math.round(Math.sqrt(xMove * xMove + yMove * yMove));
self.oldDistance = oldDistance;
};
self.__twoTouchMove = function (touch0, touch1) {
var oldScale = self.oldScale;
var oldDistance = self.oldDistance;
var scale = self.scale;
var zoom = self.zoom;
self.newScale = getNewScale(oldScale, oldDistance, zoom, touch0, touch1);
// 设定缩放范围
self.newScale <= 1 && (self.newScale = 1);
self.newScale >= scale && (self.newScale = scale);
self.scaleWidth = Math.round(self.newScale * self.baseWidth);
self.scaleHeight = Math.round(self.newScale * self.baseHeight);
var imgLeft = Math.round(self.touchX1 - self.scaleWidth / 2);
var imgTop = Math.round(self.touchY1 - self.scaleHeight / 2);
self.outsideBound(imgLeft, imgTop);
self.updateCanvas();
};
self.__xtouchEnd = function () {
self.oldScale = self.newScale;
self.rectX = self.imgLeft;
self.rectY = self.imgTop;
};
}
var handle = {
// 图片手势初始监测
touchStart: function touchStart (e) {
var self = this;
var ref = e.touches;
var touch0 = ref[0];
var touch1 = ref[1];
setTouchState(self, true, null, null);
// 计算第一个触摸点的位置,并参照改点进行缩放
self.__oneTouchStart(touch0);
// 两指手势触发
if (e.touches.length >= 2) {
self.__twoTouchStart(touch0, touch1);
}
},
// 图片手势动态缩放
touchMove: function touchMove (e) {
var self = this;
var ref = e.touches;
var touch0 = ref[0];
var touch1 = ref[1];
setTouchState(self, null, true);
// 单指手势时触发
if (e.touches.length === 1) {
self.__oneTouchMove(touch0);
}
// 两指手势触发
if (e.touches.length >= 2) {
self.__twoTouchMove(touch0, touch1);
}
},
touchEnd: function touchEnd (e) {
var self = this;
setTouchState(self, false, false, true);
self.__xtouchEnd();
}
};
function cut () {
var self = this;
var boundWidth = self.width; // 裁剪框默认宽度,即整个画布宽度
var boundHeight = self.height;
// 裁剪框默认高度,即整个画布高度
var ref = self.cut;
var x = ref.x; if ( x === void 0 ) x = 0;
var y = ref.y; if ( y === void 0 ) y = 0;
var width = ref.width; if ( width === void 0 ) width = boundWidth;
var height = ref.height; if ( height === void 0 ) height = boundHeight;
/**
* 设置边界
* @param imgLeft 图片左上角横坐标值
* @param imgTop 图片左上角纵坐标值
*/
self.outsideBound = function (imgLeft, imgTop) {
self.imgLeft = imgLeft >= x
? x
: self.scaleWidth + imgLeft - x <= width
? x + width - self.scaleWidth
: imgLeft;
self.imgTop = imgTop >= y
? y
: self.scaleHeight + imgTop - y <= height
? y + height - self.scaleHeight
: imgTop;
};
/**
* 设置边界样式
* @param color 边界颜色
*/
self.setBoundStyle = function (ref) {
if ( ref === void 0 ) ref = {};
var color = ref.color; if ( color === void 0 ) color = '#04b00f';
var mask = ref.mask; if ( mask === void 0 ) mask = 'rgba(0, 0, 0, 0.3)';
var lineWidth = ref.lineWidth; if ( lineWidth === void 0 ) lineWidth = 1;
var boundOption = [
{
start: { x: x - lineWidth, y: y + 10 - lineWidth },
step1: { x: x - lineWidth, y: y - lineWidth },
step2: { x: x + 10 - lineWidth, y: y - lineWidth }
},
{
start: { x: x - lineWidth, y: y + height - 10 + lineWidth },
step1: { x: x - lineWidth, y: y + height + lineWidth },
step2: { x: x + 10 - lineWidth, y: y + height + lineWidth }
},
{
start: { x: x + width - 10 + lineWidth, y: y - lineWidth },
step1: { x: x + width + lineWidth, y: y - lineWidth },
step2: { x: x + width + lineWidth, y: y + 10 - lineWidth }
},
{
start: { x: x + width + lineWidth, y: y + height - 10 + lineWidth },
step1: { x: x + width + lineWidth, y: y + height + lineWidth },
step2: { x: x + width - 10 + lineWidth, y: y + height + lineWidth }
}
];
// 绘制半透明层
self.ctx.beginPath();
self.ctx.setFillStyle(mask);
self.ctx.fillRect(0, 0, x, boundHeight);
self.ctx.fillRect(x, 0, width, y);
self.ctx.fillRect(x, y + height, width, boundHeight - y - height);
self.ctx.fillRect(x + width, 0, boundWidth - x - width, boundHeight);
self.ctx.fill();
boundOption.forEach(function (op) {
self.ctx.beginPath();
self.ctx.setStrokeStyle(color);
self.ctx.setLineWidth(lineWidth);
self.ctx.moveTo(op.start.x, op.start.y);
self.ctx.lineTo(op.step1.x, op.step1.y);
self.ctx.lineTo(op.step2.x, op.step2.y);
self.ctx.stroke();
});
};
}
var version = "1.2.0";
var WeCropper = function WeCropper (params) {
var self = this;
var _default = {};
validator(self, DEFAULT);
Object.keys(DEFAULT).forEach(function (key) {
_default[key] = DEFAULT[key].default;
});
Object.assign(self, _default, params);
self.prepare();
self.attachPage();
self.createCtx();
self.observer();
self.cutt();
self.methods();
self.init();
self.update();
return self
};
WeCropper.prototype.init = function init () {
var self = this;
var src = self.src;
self.version = version;
typeof self.onReady === 'function' && self.onReady(self.ctx, self);
if (src) {
self.pushOrign(src);
}
setTouchState(self, false, false, false);
self.oldScale = 1;
self.newScale = 1;
return self
};
Object.assign(WeCropper.prototype, handle);
WeCropper.prototype.prepare = prepare;
WeCropper.prototype.observer = observer;
WeCropper.prototype.methods = methods;
WeCropper.prototype.cutt = cut;
WeCropper.prototype.update = update;
return WeCropper;
})));
... ...
/**
* we-cropper v1.2.0
* (c) 2018 dlhandsome
* @license MIT
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.WeCropper = factory());
}(this, (function () { 'use strict';
var device = void 0;
var TOUCH_STATE = ['touchstarted', 'touchmoved', 'touchended'];
function isFunction (obj) {
return typeof obj === 'function'
}
function firstLetterUpper (str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
function setTouchState (instance) {
var arg = [], len = arguments.length - 1;
while ( len-- > 0 ) arg[ len ] = arguments[ len + 1 ];
TOUCH_STATE.forEach(function (key, i) {
if (arg[i] !== undefined) {
instance[key] = arg[i];
}
});
}
function validator (instance, o) {
Object.defineProperties(instance, o);
}
function getDevice () {
if (!device) {
device = wx.getSystemInfoSync();
}
return device
}
var tmp = {};
var DEFAULT = {
id: {
default: 'cropper',
get: function get () {
return tmp.id
},
set: function set (value) {
if (typeof (value) !== 'string') {
console.error(("id:" + value + " is invalid"));
}
tmp.id = value;
}
},
width: {
default: 750,
get: function get () {
return tmp.width
},
set: function set (value) {
if (typeof (value) !== 'number') {
console.error(("width:" + value + " is invalid"));
}
tmp.width = value;
}
},
height: {
default: 750,
get: function get () {
return tmp.height
},
set: function set (value) {
if (typeof (value) !== 'number') {
console.error(("height:" + value + " is invalid"));
}
tmp.height = value;
}
},
scale: {
default: 2.5,
get: function get () {
return tmp.scale
},
set: function set (value) {
if (typeof (value) !== 'number') {
console.error(("scale:" + value + " is invalid"));
}
tmp.scale = value;
}
},
zoom: {
default: 5,
get: function get () {
return tmp.zoom
},
set: function set (value) {
if (typeof (value) !== 'number') {
console.error(("zoom:" + value + " is invalid"));
} else if (value < 0 || value > 10) {
console.error("zoom should be ranged in 0 ~ 10");
}
tmp.zoom = value;
}
},
src: {
default: 'cropper',
get: function get () {
return tmp.src
},
set: function set (value) {
if (typeof (value) !== 'string') {
console.error(("id:" + value + " is invalid"));
}
tmp.src = value;
}
},
cut: {
default: {},
get: function get () {
return tmp.cut
},
set: function set (value) {
if (typeof (value) !== 'object') {
console.error(("id:" + value + " is invalid"));
}
tmp.cut = value;
}
},
onReady: {
default: null,
get: function get () {
return tmp.ready
},
set: function set (value) {
tmp.ready = value;
}
},
onBeforeImageLoad: {
default: null,
get: function get () {
return tmp.beforeImageLoad
},
set: function set (value) {
tmp.beforeImageLoad = value;
}
},
onImageLoad: {
default: null,
get: function get () {
return tmp.imageLoad
},
set: function set (value) {
tmp.imageLoad = value;
}
},
onBeforeDraw: {
default: null,
get: function get () {
return tmp.beforeDraw
},
set: function set (value) {
tmp.beforeDraw = value;
}
}
};
function prepare () {
var self = this;
var ref = getDevice();
var windowWidth = ref.windowWidth;
self.attachPage = function () {
var pages = getCurrentPages();
// 获取到当前page上下文
var pageContext = pages[pages.length - 1];
// 把this依附在Page上下文的wecropper属性上,便于在page钩子函数中访问
pageContext.wecropper = self;
};
self.createCtx = function () {
var id = self.id;
if (id) {
self.ctx = wx.createCanvasContext(id);
} else {
console.error("constructor: create canvas context failed, 'id' must be valuable");
}
};
self.deviceRadio = windowWidth / 750;
}
function observer () {
var self = this;
var EVENT_TYPE = ['ready', 'beforeImageLoad', 'beforeDraw', 'imageLoad'];
self.on = function (event, fn) {
if (EVENT_TYPE.indexOf(event) > -1) {
if (typeof (fn) === 'function') {
event === 'ready'
? fn(self)
: self[("on" + (firstLetterUpper(event)))] = fn;
}
} else {
console.error(("event: " + event + " is invalid"));
}
return self
};
}
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var base64 = createCommonjsModule(function (module, exports) {
/*! http://mths.be/base64 v0.1.0 by @mathias | MIT license */
(function(root) {
// Detect free variables `exports`.
var freeExports = 'object' == 'object' && exports;
// Detect free variable `module`.
var freeModule = 'object' == 'object' && module &&
module.exports == freeExports && module;
// Detect free variable `global`, from Node.js or Browserified code, and use
// it as `root`.
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
root = freeGlobal;
}
/*--------------------------------------------------------------------------*/
var InvalidCharacterError = function(message) {
this.message = message;
};
InvalidCharacterError.prototype = new Error;
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
var error = function(message) {
// Note: the error messages used throughout this file match those used by
// the native `atob`/`btoa` implementation in Chromium.
throw new InvalidCharacterError(message);
};
var TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// http://whatwg.org/html/common-microsyntaxes.html#space-character
var REGEX_SPACE_CHARACTERS = /[\t\n\f\r ]/g;
// `decode` is designed to be fully compatible with `atob` as described in the
// HTML Standard. http://whatwg.org/html/webappapis.html#dom-windowbase64-atob
// The optimized base64-decoding algorithm used is based on @atk’s excellent
// implementation. https://gist.github.com/atk/1020396
var decode = function(input) {
input = String(input)
.replace(REGEX_SPACE_CHARACTERS, '');
var length = input.length;
if (length % 4 == 0) {
input = input.replace(/==?$/, '');
length = input.length;
}
if (
length % 4 == 1 ||
// http://whatwg.org/C#alphanumeric-ascii-characters
/[^+a-zA-Z0-9/]/.test(input)
) {
error(
'Invalid character: the string to be decoded is not correctly encoded.'
);
}
var bitCounter = 0;
var bitStorage;
var buffer;
var output = '';
var position = -1;
while (++position < length) {
buffer = TABLE.indexOf(input.charAt(position));
bitStorage = bitCounter % 4 ? bitStorage * 64 + buffer : buffer;
// Unless this is the first of a group of 4 characters…
if (bitCounter++ % 4) {
// …convert the first 8 bits to a single ASCII character.
output += String.fromCharCode(
0xFF & bitStorage >> (-2 * bitCounter & 6)
);
}
}
return output;
};
// `encode` is designed to be fully compatible with `btoa` as described in the
// HTML Standard: http://whatwg.org/html/webappapis.html#dom-windowbase64-btoa
var encode = function(input) {
input = String(input);
if (/[^\0-\xFF]/.test(input)) {
// Note: no need to special-case astral symbols here, as surrogates are
// matched, and the input is supposed to only contain ASCII anyway.
error(
'The string to be encoded contains characters outside of the ' +
'Latin1 range.'
);
}
var padding = input.length % 3;
var output = '';
var position = -1;
var a;
var b;
var c;
var buffer;
// Make sure any padding is handled outside of the loop.
var length = input.length - padding;
while (++position < length) {
// Read three bytes, i.e. 24 bits.
a = input.charCodeAt(position) << 16;
b = input.charCodeAt(++position) << 8;
c = input.charCodeAt(++position);
buffer = a + b + c;
// Turn the 24 bits into four chunks of 6 bits each, and append the
// matching character for each of them to the output.
output += (
TABLE.charAt(buffer >> 18 & 0x3F) +
TABLE.charAt(buffer >> 12 & 0x3F) +
TABLE.charAt(buffer >> 6 & 0x3F) +
TABLE.charAt(buffer & 0x3F)
);
}
if (padding == 2) {
a = input.charCodeAt(position) << 8;
b = input.charCodeAt(++position);
buffer = a + b;
output += (
TABLE.charAt(buffer >> 10) +
TABLE.charAt((buffer >> 4) & 0x3F) +
TABLE.charAt((buffer << 2) & 0x3F) +
'='
);
} else if (padding == 1) {
buffer = input.charCodeAt(position);
output += (
TABLE.charAt(buffer >> 2) +
TABLE.charAt((buffer << 4) & 0x3F) +
'=='
);
}
return output;
};
var base64 = {
'encode': encode,
'decode': decode,
'version': '0.1.0'
};
// Some AMD build optimizers, like r.js, check for specific condition patterns
// like the following:
if (
typeof undefined == 'function' &&
typeof undefined.amd == 'object' &&
undefined.amd
) {
undefined(function() {
return base64;
});
} else if (freeExports && !freeExports.nodeType) {
if (freeModule) { // in Node.js or RingoJS v0.8.0+
freeModule.exports = base64;
} else { // in Narwhal or RingoJS v0.7.0-
for (var key in base64) {
base64.hasOwnProperty(key) && (freeExports[key] = base64[key]);
}
}
} else { // in Rhino or a web browser
root.base64 = base64;
}
}(commonjsGlobal));
});
function makeURI (strData, type) {
return 'data:' + type + ';base64,' + strData
}
function fixType (type) {
type = type.toLowerCase().replace(/jpg/i, 'jpeg');
var r = type.match(/png|jpeg|bmp|gif/)[0];
return 'image/' + r
}
function encodeData (data) {
var str = '';
if (typeof data === 'string') {
str = data;
} else {
for (var i = 0; i < data.length; i++) {
str += String.fromCharCode(data[i]);
}
}
return base64.encode(str)
}
/**
* 获取图像区域隐含的像素数据
* @param canvasId canvas标识
* @param x 将要被提取的图像数据矩形区域的左上角 x 坐标
* @param y 将要被提取的图像数据矩形区域的左上角 y 坐标
* @param width 将要被提取的图像数据矩形区域的宽度
* @param height 将要被提取的图像数据矩形区域的高度
* @param done 完成回调
*/
function getImageData (canvasId, x, y, width, height, done) {
wx.canvasGetImageData({
canvasId: canvasId,
x: x,
y: y,
width: width,
height: height,
success: function success (res) {
done(res);
},
fail: function fail (res) {
done(null);
console.error('canvasGetImageData error: ' + res);
}
});
}
/**
* 生成bmp格式图片
* 按照规则生成图片响应头和响应体
* @param oData 用来描述 canvas 区域隐含的像素数据 { data, width, height } = oData
* @returns {*} base64字符串
*/
function genBitmapImage (oData) {
//
// BITMAPFILEHEADER: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183374(v=vs.85).aspx
// BITMAPINFOHEADER: http://msdn.microsoft.com/en-us/library/dd183376.aspx
//
var biWidth = oData.width;
var biHeight = oData.height;
var biSizeImage = biWidth * biHeight * 3;
var bfSize = biSizeImage + 54; // total header size = 54 bytes
//
// typedef struct tagBITMAPFILEHEADER {
// WORD bfType;
// DWORD bfSize;
// WORD bfReserved1;
// WORD bfReserved2;
// DWORD bfOffBits;
// } BITMAPFILEHEADER;
//
var BITMAPFILEHEADER = [
// WORD bfType -- The file type signature; must be "BM"
0x42, 0x4D,
// DWORD bfSize -- The size, in bytes, of the bitmap file
bfSize & 0xff, bfSize >> 8 & 0xff, bfSize >> 16 & 0xff, bfSize >> 24 & 0xff,
// WORD bfReserved1 -- Reserved; must be zero
0, 0,
// WORD bfReserved2 -- Reserved; must be zero
0, 0,
// DWORD bfOffBits -- The offset, in bytes, from the beginning of the BITMAPFILEHEADER structure to the bitmap bits.
54, 0, 0, 0
];
//
// typedef struct tagBITMAPINFOHEADER {
// DWORD biSize;
// LONG biWidth;
// LONG biHeight;
// WORD biPlanes;
// WORD biBitCount;
// DWORD biCompression;
// DWORD biSizeImage;
// LONG biXPelsPerMeter;
// LONG biYPelsPerMeter;
// DWORD biClrUsed;
// DWORD biClrImportant;
// } BITMAPINFOHEADER, *PBITMAPINFOHEADER;
//
var BITMAPINFOHEADER = [
// DWORD biSize -- The number of bytes required by the structure
40, 0, 0, 0,
// LONG biWidth -- The width of the bitmap, in pixels
biWidth & 0xff, biWidth >> 8 & 0xff, biWidth >> 16 & 0xff, biWidth >> 24 & 0xff,
// LONG biHeight -- The height of the bitmap, in pixels
biHeight & 0xff, biHeight >> 8 & 0xff, biHeight >> 16 & 0xff, biHeight >> 24 & 0xff,
// WORD biPlanes -- The number of planes for the target device. This value must be set to 1
1, 0,
// WORD biBitCount -- The number of bits-per-pixel, 24 bits-per-pixel -- the bitmap
// has a maximum of 2^24 colors (16777216, Truecolor)
24, 0,
// DWORD biCompression -- The type of compression, BI_RGB (code 0) -- uncompressed
0, 0, 0, 0,
// DWORD biSizeImage -- The size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps
biSizeImage & 0xff, biSizeImage >> 8 & 0xff, biSizeImage >> 16 & 0xff, biSizeImage >> 24 & 0xff,
// LONG biXPelsPerMeter, unused
0, 0, 0, 0,
// LONG biYPelsPerMeter, unused
0, 0, 0, 0,
// DWORD biClrUsed, the number of color indexes of palette, unused
0, 0, 0, 0,
// DWORD biClrImportant, unused
0, 0, 0, 0
];
var iPadding = (4 - ((biWidth * 3) % 4)) % 4;
var aImgData = oData.data;
var strPixelData = '';
var biWidth4 = biWidth << 2;
var y = biHeight;
var fromCharCode = String.fromCharCode;
do {
var iOffsetY = biWidth4 * (y - 1);
var strPixelRow = '';
for (var x = 0; x < biWidth; x++) {
var iOffsetX = x << 2;
strPixelRow += fromCharCode(aImgData[iOffsetY + iOffsetX + 2]) +
fromCharCode(aImgData[iOffsetY + iOffsetX + 1]) +
fromCharCode(aImgData[iOffsetY + iOffsetX]);
}
for (var c = 0; c < iPadding; c++) {
strPixelRow += String.fromCharCode(0);
}
strPixelData += strPixelRow;
} while (--y)
var strEncoded = encodeData(BITMAPFILEHEADER.concat(BITMAPINFOHEADER)) + encodeData(strPixelData);
return strEncoded
}
/**
* 转换为图片base64
* @param canvasId canvas标识
* @param x 将要被提取的图像数据矩形区域的左上角 x 坐标
* @param y 将要被提取的图像数据矩形区域的左上角 y 坐标
* @param width 将要被提取的图像数据矩形区域的宽度
* @param height 将要被提取的图像数据矩形区域的高度
* @param type 转换图片类型
* @param done 完成回调
*/
function convertToImage (canvasId, x, y, width, height, type, done) {
if ( done === void 0 ) done = function () {};
if (type === undefined) { type = 'png'; }
type = fixType(type);
if (/bmp/.test(type)) {
getImageData(canvasId, x, y, width, height, function (data) {
var strData = genBitmapImage(data);
isFunction(done) && done(makeURI(strData, 'image/' + type));
});
} else {
console.error('暂不支持生成\'' + type + '\'类型的base64图片');
}
}
var CanvasToBase64 = {
convertToImage: convertToImage,
// convertToPNG: function (width, height, done) {
// return convertToImage(width, height, 'png', done)
// },
// convertToJPEG: function (width, height, done) {
// return convertToImage(width, height, 'jpeg', done)
// },
// convertToGIF: function (width, height, done) {
// return convertToImage(width, height, 'gif', done)
// },
convertToBMP: function (ref, done) {
if ( ref === void 0 ) ref = {};
var canvasId = ref.canvasId;
var x = ref.x;
var y = ref.y;
var width = ref.width;
var height = ref.height;
if ( done === void 0 ) done = function () {};
return convertToImage(canvasId, x, y, width, height, 'bmp', done)
}
};
function methods () {
var self = this;
var id = self.id;
var deviceRadio = self.deviceRadio;
var boundWidth = self.width; // 裁剪框默认宽度,即整个画布宽度
var boundHeight = self.height; // 裁剪框默认高度,即整个画布高度
var ref = self.cut;
var x = ref.x; if ( x === void 0 ) x = 0;
var y = ref.y; if ( y === void 0 ) y = 0;
var width = ref.width; if ( width === void 0 ) width = boundWidth;
var height = ref.height; if ( height === void 0 ) height = boundHeight;
self.updateCanvas = function () {
if (self.croperTarget) {
// 画布绘制图片
self.ctx.drawImage(self.croperTarget, self.imgLeft, self.imgTop, self.scaleWidth, self.scaleHeight);
}
isFunction(self.onBeforeDraw) && self.onBeforeDraw(self.ctx, self);
self.setBoundStyle(); // 设置边界样式
self.ctx.draw();
return self
};
self.pushOrign = function (src) {
self.src = src;
isFunction(self.onBeforeImageLoad) && self.onBeforeImageLoad(self.ctx, self);
wx.getImageInfo({
src: src,
success: function success (res) {
var innerAspectRadio = res.width / res.height;
self.croperTarget = res.path;
if (innerAspectRadio < width / height) {
self.rectX = x;
self.baseWidth = width;
self.baseHeight = width / innerAspectRadio;
self.rectY = y - Math.abs((height - self.baseHeight) / 2);
} else {
self.rectY = y;
self.baseWidth = height * innerAspectRadio;
self.baseHeight = height;
self.rectX = x - Math.abs((width - self.baseWidth) / 2);
}
self.imgLeft = self.rectX;
self.imgTop = self.rectY;
self.scaleWidth = self.baseWidth;
self.scaleHeight = self.baseHeight;
self.updateCanvas();
isFunction(self.onImageLoad) && self.onImageLoad(self.ctx, self);
}
});
self.update();
return self
};
self.getCropperBase64 = function (done) {
if ( done === void 0 ) done = function () {};
CanvasToBase64.convertToBMP({
canvasId: id,
x: x,
y: y,
width: width,
height: height
}, done);
};
self.getCropperImage = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var ARG_TYPE = toString.call(args[0]);
var fn = args[args.length - 1];
switch (ARG_TYPE) {
case '[object Object]':
var ref = args[0];
var quality = ref.quality; if ( quality === void 0 ) quality = 10;
if (typeof (quality) !== 'number') {
console.error(("quality:" + quality + " is invalid"));
} else if (quality < 0 || quality > 10) {
console.error("quality should be ranged in 0 ~ 10");
}
wx.canvasToTempFilePath({
canvasId: id,
x: x,
y: y,
width: width,
height: height,
destWidth: width * quality / (deviceRadio * 10),
destHeight: height * quality / (deviceRadio * 10),
success: function success (res) {
isFunction(fn) && fn.call(self, res.tempFilePath);
},
fail: function fail (res) {
isFunction(fn) && fn.call(self, null);
}
}); break
case '[object Function]':
wx.canvasToTempFilePath({
canvasId: id,
x: x,
y: y,
width: width,
height: height,
destWidth: width / deviceRadio,
destHeight: height / deviceRadio,
success: function success (res) {
isFunction(fn) && fn.call(self, res.tempFilePath);
},
fail: function fail (res) {
isFunction(fn) && fn.call(self, null);
}
}); break
}
return self
};
}
/**
* 获取最新缩放值
* @param oldScale 上一次触摸结束后的缩放值
* @param oldDistance 上一次触摸结束后的双指距离
* @param zoom 缩放系数
* @param touch0 第一指touch对象
* @param touch1 第二指touch对象
* @returns {*}
*/
var getNewScale = function (oldScale, oldDistance, zoom, touch0, touch1) {
var xMove, yMove, newDistance;
// 计算二指最新距离
xMove = Math.round(touch1.x - touch0.x);
yMove = Math.round(touch1.y - touch0.y);
newDistance = Math.round(Math.sqrt(xMove * xMove + yMove * yMove));
return oldScale + 0.001 * zoom * (newDistance - oldDistance)
};
function update () {
var self = this;
if (!self.src) { return }
self.__oneTouchStart = function (touch) {
self.touchX0 = Math.round(touch.x);
self.touchY0 = Math.round(touch.y);
};
self.__oneTouchMove = function (touch) {
var xMove, yMove;
// 计算单指移动的距离
if (self.touchended) {
return self.updateCanvas()
}
xMove = Math.round(touch.x - self.touchX0);
yMove = Math.round(touch.y - self.touchY0);
var imgLeft = Math.round(self.rectX + xMove);
var imgTop = Math.round(self.rectY + yMove);
self.outsideBound(imgLeft, imgTop);
self.updateCanvas();
};
self.__twoTouchStart = function (touch0, touch1) {
var xMove, yMove, oldDistance;
self.touchX1 = Math.round(self.rectX + self.scaleWidth / 2);
self.touchY1 = Math.round(self.rectY + self.scaleHeight / 2);
// 计算两指距离
xMove = Math.round(touch1.x - touch0.x);
yMove = Math.round(touch1.y - touch0.y);
oldDistance = Math.round(Math.sqrt(xMove * xMove + yMove * yMove));
self.oldDistance = oldDistance;
};
self.__twoTouchMove = function (touch0, touch1) {
var oldScale = self.oldScale;
var oldDistance = self.oldDistance;
var scale = self.scale;
var zoom = self.zoom;
self.newScale = getNewScale(oldScale, oldDistance, zoom, touch0, touch1);
// 设定缩放范围
self.newScale <= 1 && (self.newScale = 1);
self.newScale >= scale && (self.newScale = scale);
self.scaleWidth = Math.round(self.newScale * self.baseWidth);
self.scaleHeight = Math.round(self.newScale * self.baseHeight);
var imgLeft = Math.round(self.touchX1 - self.scaleWidth / 2);
var imgTop = Math.round(self.touchY1 - self.scaleHeight / 2);
self.outsideBound(imgLeft, imgTop);
self.updateCanvas();
};
self.__xtouchEnd = function () {
self.oldScale = self.newScale;
self.rectX = self.imgLeft;
self.rectY = self.imgTop;
};
}
var handle = {
// 图片手势初始监测
touchStart: function touchStart (e) {
var self = this;
var ref = e.touches;
var touch0 = ref[0];
var touch1 = ref[1];
setTouchState(self, true, null, null);
// 计算第一个触摸点的位置,并参照改点进行缩放
self.__oneTouchStart(touch0);
// 两指手势触发
if (e.touches.length >= 2) {
self.__twoTouchStart(touch0, touch1);
}
},
// 图片手势动态缩放
touchMove: function touchMove (e) {
var self = this;
var ref = e.touches;
var touch0 = ref[0];
var touch1 = ref[1];
setTouchState(self, null, true);
// 单指手势时触发
if (e.touches.length === 1) {
self.__oneTouchMove(touch0);
}
// 两指手势触发
if (e.touches.length >= 2) {
self.__twoTouchMove(touch0, touch1);
}
},
touchEnd: function touchEnd (e) {
var self = this;
setTouchState(self, false, false, true);
self.__xtouchEnd();
}
};
function cut () {
var self = this;
var boundWidth = self.width; // 裁剪框默认宽度,即整个画布宽度
var boundHeight = self.height;
// 裁剪框默认高度,即整个画布高度
var ref = self.cut;
var x = ref.x; if ( x === void 0 ) x = 0;
var y = ref.y; if ( y === void 0 ) y = 0;
var width = ref.width; if ( width === void 0 ) width = boundWidth;
var height = ref.height; if ( height === void 0 ) height = boundHeight;
/**
* 设置边界
* @param imgLeft 图片左上角横坐标值
* @param imgTop 图片左上角纵坐标值
*/
self.outsideBound = function (imgLeft, imgTop) {
self.imgLeft = imgLeft >= x
? x
: self.scaleWidth + imgLeft - x <= width
? x + width - self.scaleWidth
: imgLeft;
self.imgTop = imgTop >= y
? y
: self.scaleHeight + imgTop - y <= height
? y + height - self.scaleHeight
: imgTop;
};
/**
* 设置边界样式
* @param color 边界颜色
*/
self.setBoundStyle = function (ref) {
if ( ref === void 0 ) ref = {};
var color = ref.color; if ( color === void 0 ) color = '#04b00f';
var mask = ref.mask; if ( mask === void 0 ) mask = 'rgba(0, 0, 0, 0.3)';
var lineWidth = ref.lineWidth; if ( lineWidth === void 0 ) lineWidth = 1;
var boundOption = [
{
start: { x: x - lineWidth, y: y + 10 - lineWidth },
step1: { x: x - lineWidth, y: y - lineWidth },
step2: { x: x + 10 - lineWidth, y: y - lineWidth }
},
{
start: { x: x - lineWidth, y: y + height - 10 + lineWidth },
step1: { x: x - lineWidth, y: y + height + lineWidth },
step2: { x: x + 10 - lineWidth, y: y + height + lineWidth }
},
{
start: { x: x + width - 10 + lineWidth, y: y - lineWidth },
step1: { x: x + width + lineWidth, y: y - lineWidth },
step2: { x: x + width + lineWidth, y: y + 10 - lineWidth }
},
{
start: { x: x + width + lineWidth, y: y + height - 10 + lineWidth },
step1: { x: x + width + lineWidth, y: y + height + lineWidth },
step2: { x: x + width - 10 + lineWidth, y: y + height + lineWidth }
}
];
// 绘制半透明层
self.ctx.beginPath();
self.ctx.setFillStyle(mask);
self.ctx.fillRect(0, 0, x, boundHeight);
self.ctx.fillRect(x, 0, width, y);
self.ctx.fillRect(x, y + height, width, boundHeight - y - height);
self.ctx.fillRect(x + width, 0, boundWidth - x - width, boundHeight);
self.ctx.fill();
boundOption.forEach(function (op) {
self.ctx.beginPath();
self.ctx.setStrokeStyle(color);
self.ctx.setLineWidth(lineWidth);
self.ctx.moveTo(op.start.x, op.start.y);
self.ctx.lineTo(op.step1.x, op.step1.y);
self.ctx.lineTo(op.step2.x, op.step2.y);
self.ctx.stroke();
});
};
}
var version = "1.2.0";
var WeCropper = function WeCropper (params) {
var self = this;
var _default = {};
validator(self, DEFAULT);
Object.keys(DEFAULT).forEach(function (key) {
_default[key] = DEFAULT[key].default;
});
Object.assign(self, _default, params);
self.prepare();
self.attachPage();
self.createCtx();
self.observer();
self.cutt();
self.methods();
self.init();
self.update();
return self
};
WeCropper.prototype.init = function init () {
var self = this;
var src = self.src;
self.version = version;
typeof self.onReady === 'function' && self.onReady(self.ctx, self);
if (src) {
self.pushOrign(src);
}
setTouchState(self, false, false, false);
self.oldScale = 1;
self.newScale = 1;
return self
};
Object.assign(WeCropper.prototype, handle);
WeCropper.prototype.prepare = prepare;
WeCropper.prototype.observer = observer;
WeCropper.prototype.methods = methods;
WeCropper.prototype.cutt = cut;
WeCropper.prototype.update = update;
return WeCropper;
})));
... ...
<template name="we-cropper">
<canvas
class="cropper"
disable-scroll="true"
bindtouchstart="touchStart"
bindtouchmove="touchMove"
bindtouchend="touchEnd"
style="width:{{width}}px;height:{{height}}px;background-color: rgba(0, 0, 0, 0.8)"
canvas-id="{{id}}">
</canvas>
</template>
\ No newline at end of file
... ...
@font-face {font-family: "iconfont";
src: url('//at.alicdn.com/t/font_999857_g3vfsyotxtv.eot?t=1550544314216'); /* IE9 */
src: url('//at.alicdn.com/t/font_999857_g3vfsyotxtv.eot?t=1550544314216#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAXsAAsAAAAAC7gAAAWfAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCEAgqJFIdsATYCJAMkCxQABCAFhG0HgSIbMgojESZ0s072lwmcXMLqbICJmlODRajLtGueGZWrJ3WvcV84uCYfvi59H+vsBtKkZEhMYdzgU8BCOHVu6Q0eItzd6hdThGGaB9gCCQD637lM3lxhSApQo3BTB+QGRKqxjT0ChTAERZD+6nEDBMCgBT32mSqW6er0xYY5w1Idb33bdUcCpUj6EM4C4Pj7Fe+2RmGOra3Lm62oiwz6ekcJdEARbdF6QEULxKcSXktvAl+8GghAy4mA9PDYVKhx9k4EQGZVRRHUBR/ewSPUTmXDkQE5UFCXTfQBgB3R35OPOakBSlFhXyuxPKwUgRKkIibKO7lMhLhcBIB4HMAAAoADuY2xrWBJnYDR6i25QgAmjpSB9H2dZCZ5SQFSvFQkyxW2MBI2MkkPmlkCUJ1blOF7/+cBabBtRmA11qtBgqcGFUg6XZPdDB4Q2L3ggRJ2AR4w2APgAYc9Hh5Q2IvQBwoAoAnsZmgkA6BPpmNZtBFBUBSnSNJBjHWVgm3B3gOLYiVXX1JdtUX3o0kkXjU5kZi9vuPp6WW+LpTCxBMP02DUhcREk5fB3IWyDOYUYLbGjk9zZc+Pefpwmye1oRwmgfjhltx71BbrP+Fk9sqQophMFlW1EHgHbsd8qWIAM2PGpp5U1ZhsNO7e1TCPNUmAudhihr4PUhFgShBw5NpT7Meo/JrUfwv8bbsWM8N8TexnSY5VFjjiNIqoFOHEO81x2P/eLey91iNOjkjRihJHnMQWSbxKtHGdkTAjHLw3DuwQ5UUax9qe3te1STtx0IoJm1Q+bpVFd9WYnwMz4AN72+NBS5NkZMw6aNUrnwMP3wf8MuXWcmyvtAOWKvxRMKK0dKFHN9s71xXFO9u9Td+VUX3f3uxzxb+mfxWfzewHsxebZNikuSbODrPdZ398r3247WyXRNs0k4zF2YeHfMy0+7+Ox2YO97Myd2W8sXOKF/OXneubcLL8/rAAx9/MeekyOOjyco4Q6zzkHCeQ8pNjmzrDVzokuMupMZQLTnFDcc4Clk757JncdUey02/enGYg8LPT2RkiewNinj0/aOueN/fpU7rp6tVNvpkShW6iOZDlwcPRPGSM//6dS4cE6JtYd/JAIN1w/foGmCmj0A3UbVnHW+7iwt86hNA3sW76M09uc5WKw3ybIcpcpea3HEI1oX633lSfrzexNzHkG0wf5tb+6nAiUBUmrmxMUwWekCr2pk+WPqHzVK3Um46vfEKMAvuPvR8V09Qf9Q1hw0eDxx3V2z4UDvygTsPO/vT0CouvFu0VlR2+pV0/ezlke8XZ1si4wPuXL5Lc7u5cEkOLg/PyGIma55LubpJ7sZF07N0aefbu8WhSUoJok/Me36en2TlMz5PokpJokqbMyVZWnsTlzPh+6BEBQP7kOF0NAGzRt4A87BQL5AXjjstf+Iglcv/VQAoA7NEvf5atEJaSb1FgvOybmn/FF7zZtX2QNpPFBtsA1CblQeCvoR84jRtG26+JNn5PNyGhkf69qVCA1qEAf4mUmU/LOiwH2/APdFhmQKk4AqPmQeMsARR05oGS2krQ8hdxvI65ZjAkGgB+1nFAmLgElMEYMCYe0jjrIyhYmQYlkxhopRPzM+p4tdM9vGYUjBrkBZyiZNwgP8Sdv9DWIHLeGMn+MBdXhKHty42fmDAvsU852pHZgMkU4YO7HoZAsGSaUXE7MS+HrjNNz9QqiqsHIRkFowZ5AacomWB+fqj8/hfaGkTuGFXX/MNc3OphaPsBtE9bGjTqUXqWox2ZKgaM2JEifFAEg1NHsDRvNqPidppQWQ4dzWaG2trtHfGxXkGy7PtMhTSHy+MzbDSvIlnr77O7ijTcFKql0s25FL/iS5httEg44LZMIqmpjuwEXUe5/x0sp6mZC9U5NXPoP7s8RrGLkyBeJNmt712tAA==') format('woff2'),
url('//at.alicdn.com/t/font_999857_g3vfsyotxtv.woff?t=1550544314216') format('woff'),
url('//at.alicdn.com/t/font_999857_g3vfsyotxtv.ttf?t=1550544314216') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
url('//at.alicdn.com/t/font_999857_g3vfsyotxtv.svg?t=1550544314216#iconfont') format('svg'); /* iOS 4.1- */
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-huangguan:before {
content: "\e612";
}
.icon-zan1:before {
content: "\e64e";
}
.icon-sousuo:before {
content: "\e62c";
}
.icon-xuanze:before {
content: "\e62d";
}
.icon-xuanze-danxuan:before {
content: "\e661";
}
.icon-shanchu:before {
content: "\e626";
}
.icon-tiaozhuanqianwangyoujiantouxiangyouxiayibuxianxing:before {
content: "\e600";
}
.icon-xin:before {
content: "\e60b";
}
... ...
// pages/aboutme/aboutme.js
var wxParse = require('../../wxParse/wxParse.js')
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
aboutus:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.aboutus()
},
aboutus(){
let that = this;
var url = '/home/News/aboutUs';
var params = {
}
app.post(url, params).then((res) => {
console.log(res);
wxParse.wxParse('content', 'html', res.content, that, 5);
that.setData({
aboutus:res
})
}).catch((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/aboutme/aboutme.wxml-->
<import src="../../wxParse/wxParse.wxml" />
<view class='about'>
<view class='about_logo'>
<!-- <image src='http://bronet.wangshuwen.com/03da97edfb8f3bcd2a600d3cbcee5bb@2x.png'></image> -->
<image src='{{aboutus.logo}}'></image>
</view>
<view class='about_title'>口袋教案</view>
<view class='about_mian'>
<view class='about_miantitle'>公司简介:</view>
<view class="companytext">
<template is='wxParse' data='{{wxParseData:content.nodes}}' />
</view>
</view>
</view>
<view class='about_item' wx:if="{{aboutus.tel!=''}}">
<view class='about_img'>
<image src='http://bronet.wangshuwen.com/oiuoukkl@2x.png'></image>
</view>
<view>{{aboutus.tel}}</view>
</view>
<view class='about_item' wx:if="{{aboutus.qq!=''}}">
<view class='about_img'>
<image src='http://bronet.wangshuwen.com/yuiuopo@2x.png'></image>
</view>
<view>{{aboutus.qq}}</view>
</view>
<view class='about_item' wx:if="{{aboutus.we_chat!=''}}">
<view class='about_img'>
<image src='http://bronet.wangshuwen.com/uioyutree@2x.png'></image>
</view>
<view>{{aboutus.we_chat}}</view>
</view>
... ...
/* pages/aboutme/aboutme.wxss */
page{
background: #FAFDFF;
}
.about{
margin: 20rpx 0 70rpx 0;
padding:55rpx 0 30rpx 0;
background: #fff;
}
.about_logo{
display: flex;
justify-content: center;
align-items: center;
margin: 0 auto 0 auto;
box-sizing: border-box;
width:140rpx;
height: 140rpx;
border-radius: 50%;
overflow: hidden;
}
.about_logo image{
width:100%;
height: 100%;
display: block;
}
.about_title{
margin: 50rpx 0 76rpx 0;
text-align: center;
color:#333;
font-size:30rpx;
font-weight: bold;
}
.about_mian{
margin: 0 32rpx;
color:#333;
font-size:30rpx;
line-height: 40rpx;
}
.about_miantitle{
color:#333;
font-size:30rpx;
margin: 0 0 10rpx 0;
}
.about_item{
display: flex;
background: #fff;
align-items: center;
height: 80rpx;
padding:0 32rpx;
font-size: 30rpx;
color:#333;
}
.about_img{
width:32rpx;
height: 32rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin: 0 29rpx 0 0;
}
.about_img image{
width:100%;
height: 100%;
display: block;
}
.companytext{
/* display:flex; */
/* justify-content: center; */
}
.wxParse-p{
display:flex;
/* font-size: 0;
display:flex;
justify-content: center; */
/* margin: 0 auto; */
}
.wxParse-p image{
display:block;
}
.wxParse-p image{
width:365px;
margin:0 auto;
}
\ No newline at end of file
... ...
// pages/choseimg/choseimg.js
import WeCropper from '../../cropper/we-cropper.js'
const device = wx.getSystemInfoSync()
const width = device.windowWidth
const height = device.windowHeight - 100;
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
xx: false,
cropperOpt: { //基础设置
id: 'cropper',
width,
height,
scale: 2.5,
zoom: 8,
cut: {
x: (width - 148) / 2,
y: (height - 148) / 2,
width: 148,
height: 148
}
},
img: '../../img/upimage.png',
},
chooseimg: function () {
var that = this;
wx.chooseImage({
// sizeType: ['original', 'compressed'],
// sourceType: ['type'],
success: function (res) {
console.log(res.tempFilePaths[0])
that.setData({
cutImage: 'show',
addtribeConShow: 'hide',
xx: true
});
that.wecropper.pushOrign(res.tempFilePaths[0]);
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this
const {
cropperOpt
} = this.data
new WeCropper(cropperOpt)
.on('ready', (ctx) => { })
.on('beforeImageLoad', (ctx) => {
console.log(`before picture loaded, i can do something`)
console.log(`current canvas context:`, ctx)
wx.showToast({
title: '上传中',
icon: 'loading',
duration: 20000
})
})
.on('imageLoad', (ctx) => {
console.log(`picture loaded`)
console.log(`current canvas context:`, ctx)
wx.hideToast()
})
.on('beforeDraw', (ctx, instance) => {
console.log(`before canvas draw,i can do something`)
console.log(`current canvas context:`, ctx)
})
.updateCanvas();
},
touchStart(e) {
this.wecropper.touchStart(e)
},
touchMove(e) {
this.wecropper.touchMove(e)
},
touchEnd(e) {
this.wecropper.touchEnd(e)
},
getCropperImage() {
var that = this;
that.wecropper.getCropperImage((src) => {
console.log(src)
if (src) {
//此处添加用户确定裁剪后执行的操作 src是截取到的图片路径
that.setData({
xx: false,
img: src,
})
}
})
},
//手指离开屏幕
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class='toux'>
<image mode='scaleToFill' class='toux1' src="{{img}}" bindtap='chooseimg'></image>
<image mode='scaleToFill' class='toux2' src='../../images/toux/xiangji.png' bindtap='chooseimg'></image>
</view>
<!-- 裁剪 -->
<view class='caijain' wx:if="{{xx}}">
<!--start 用户自动截取正方形照片 -->
<!-- 裁剪区域 重要 -->
<template name="we-cropper">
<canvas class="cropper {{cutImage}}" disable-scroll="true" bindtouchstart="touchStart" bindtouchmove="touchMove" bindtouchend="touchEnd" style="width:{{width}}px;height:{{height}}px;" canvas-id="{{id}}">
</canvas>
</template>
<!-- 按钮,无所谓的东西 -->
<view class="cropper-wrapper {{cutImage}}">
<template is="we-cropper" data="{{...cropperOpt}}" />
<view class='caijananniu'>
<view class='cxuan' bindtap="chooseimg">重新选择</view>
<view class='cxuan' bindtap="getCropperImage">确定</view>
</view>
</view>
<!--end 用户自动截取正方形照片 -->
</view>
\ No newline at end of file
... ...
@import '../teachplan/teachplanlistdetail/teachplanlistdetail';
.toux{
height:100rpx;
}
\ No newline at end of file
... ...
// pages/comment/comment.js
const app=getApp();
Page({
/**
* 页面的初始数据
*/
data: {
id:'',
content:'',
suredis:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options)
this.setData({
id:options.id
})
},
//输入评论
entercomment(e){
this.setData({
content:e.detail.value
})
},
surecomment(){
let that = this;
var url = '/home/Goods/comment';
var params = {
id:that.data.id,
content: that.data.content,
}
var header={
'XX-Token': wx.getStorageSync('token'),
'XX-Device-Type':'wxapp'
}
app.post(url, params,header).then((res) => {
console.log(res);
if(res==true){
wx.showToast({
title: '评论成功',
icon:"none"
})
setTimeout(function(){
// that.setData({
// suredis:true
// })
wx.navigateBack({
checked:true
})
},1500)
}
}).catch((err) => {
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
... ...
{
"navigationBarTitleText": "评论"
}
\ No newline at end of file
... ...
<view>
<!-- <view class="commenttitle">评论</view> -->
<view class="commentconetnt">
<textarea bindblur="bindTextAreaBlur" style="width:672rpx;height:920rpx;" class="enterword" placeholder="请输入评论" bindinput="entercomment" />
</view>
<button class="surecomment" bindtap="surecomment" disabled="{{suredis}}">确定</button>
</view>
... ...
/* pages/comment/comment.wxss */
.commenttitle{
width:100%;
color:#666666;
text-align: center;
}
.commentconetnt{
width:716rpx;
height:970rpx;
margin: 0 auto;
border:1rpx solid #D1CECE;
border-radius:14rpx;
margin-top:28rpx;
padding:20rpx;
box-sizing: border-box;
font-size: 32rpx;
}
.surecomment{
width:686rpx;
height:68rpx;
background:linear-gradient(90deg,rgba(14,77,140,1),rgba(31,92,153,1));
box-shadow:0px 4px 16px 0px rgba(14,77,140,0.4), 0px 2px 6px 0px rgba(52, 209, 131, 0.35);
border-radius:30rpx;
color:#fff;
font-size: 30rpx;
text-align: center;
line-height: 68rpx;
margin: 45rpx auto 0;
}
... ...
// pages/download/download.js
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
navbar: ["阅读", "考试", "写作", "语法", "免费资源", "免费资源", "免费资源", "免费资源"],
currentTab: 0,
keyword:'',
category_id:'',
is_free:0,
downlist:[],
page:1,
state:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.mydownload();
this.showbtn()
},
//是否显示按钮、
showbtn() {
let that = this;
var url = '/home/Welcome/paySwitch';
var params = {
}
app.post(url, params).then((res) => {
console.log(res);
that.setData({
state: res.state
})
}).catch((err) => {
})
},
//输入关键字
enterword(e){
this.setData({
keyword:e.detail.value,
downlist:[],
page:1,
})
this.mydownload()
},
mydownload(){
let that = this;
var url = '/home/Center/download';
var params = {
keyword: that.data.keyword,
category_id: that.data.category_id,
is_free: that.data.is_free,
p:that.data.page
}
var header={
'XX-Token': wx.getStorageSync('token'),
'XX-Device-Type':'wxapp'
}
app.post(url, params,header).then((res) => {
console.log(res);
that.setData({
navbar: res.category,
downlist: that.data.downlist.concat(res.list)
})
}).catch((err) => {
})
},
navbarTap: function (e) {
let free=e.currentTarget.dataset.free;
let category_id = e.currentTarget.dataset.id;
if(free==undefined){
this.setData({
page: 1,
currentTab: e.currentTarget.dataset.idx,
category_id: e.currentTarget.dataset.id,
is_free: '',
downlist: []
})
this.mydownload()
}else{
console.log(8080)
this.setData({
page: 1,
currentTab: e.currentTarget.dataset.idx,
category_id:'',
is_free: e.currentTarget.dataset.free,
downlist: []
})
this.mydownload()
}
// if (e.currentTarget.dataset.idx==6){
// this.setData({
// page:1,
// currentTab: e.currentTarget.dataset.idx,
// category_id: '',
// is_free: e.currentTarget.dataset.free,
// downlist:[]
// })
// }else{
// this.setData({
// page: 1,
// currentTab: e.currentTarget.dataset.idx,
// category_id: e.currentTarget.dataset.id,
// is_free:'',
// downlist:[]
// })
// }
},
entercomment(e){
let id=e.currentTarget.dataset.id;
wx.navigateTo({
url: '../comment/comment?id='+id,
})
},
//教学方案列表详情
detail(e) {
console.log(e)
let id = e.currentTarget.dataset.id;
let free = e.currentTarget.dataset.free;
wx.navigateTo({
url: '../teachplan/teachplanlistdetail/teachplanlistdetail?id=' + id + '&free=' + free,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
let that=this;
let page = that.data.page;
page++;
that.setData({
page: page,
})
that.mydownload()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
... ...
{
"navigationBarTitleText": "我的下载"
}
\ No newline at end of file
... ...
<!--pages/download/download.wxml-->
<view class='collectbox'>
<view class='searchbox'>
<view class='iconfont icon-sousuo'></view>
<view class='search_input'>
<input placeholder='请输入您要搜索的教案内容' placeholder-class='placeholder_input' bindblur="enterword"></input>
</view>
</view>
<view class='collect_navbox'>
<!-- <view class='collect_nav collect_active'>自然拼读</view>
<view class='collect_nav'>阅读</view>
<view class='collect_nav'>考试</view>
<view class='collect_nav'>语法</view>
<view class='collect_nav'>免费资源</view> -->
<view wx:for="{{navbar}}" data-idx="{{index}}" class="collect_nav kindnav_item {{currentTab==index ? 'collect_active' : ''}}" wx:key="unique" bindtap="navbarTap" data-id="{{item.category_id}}" data-free="{{item.is_free}}">{{item.category_name}}
</view>
</view>
</view>
<view class="nodata" wx:if="{{downlist.length==0}}">暂无数据</view>
<block wx:else>
<view class='collect_item' wx:for='{{downlist}}' wx:key="" bindtap='detail' data-id="{{item.id}}" data-free="{{item.goods_price}}">
<view class='itemimg'>
<image src='{{item.thumbnail}}'></image>
</view>
<view class='itemtxt'>
<view wx:if="{{item.goods_name!=null}}">{{item.goods_name}}</view>
<view class="categry" wx:if="{{item.category!=null}}">{{item.category}}</view>
<view>浏览 {{item.hit_num}} 次</view>
<view class="commentlist">
<view class='itemprice' wx:if="{{state==1}}">{{item.goods_price}}</view>
<view class="commentword" catchtap="entercomment" data-id="{{item.id}}">评论</view>
</view>
</view>
</view>
</block>
\ No newline at end of file
... ...
/* pages/download/download.wxss */
@import '/pages/my_collect/my_collect.wxss';
.collect_navbox {
margin: 0;
padding:0 32rpx;
border-bottom:1rpx solid #e8e8e8;
overflow-x: scroll
}
.collect_nav{
padding:27rpx 24rpx;
flex:0 0 auto;
}
.commentlist{
display:flex;
justify-content: space-between;
align-items: center;
}
.commentword{
width:100rpx;
height:50rpx;
background:rgba(30,91,152,1);
border-radius:10rpx;
color:#fff;
font-size: 30rpx;
text-align: center;
line-height: 50rpx;
}
.itemtxt{
flex:1;
}
.categry{
color:#999;
}
\ No newline at end of file
... ...
// pages/explain/explain.js
var wxParse = require('../../wxParse/wxParse.js')
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getexplain()
},
getexplain(){
let that = this;
var url = '/home/Center/about';
var params = {
}
var header={
'XX-Token': wx.getStorageSync('token'),
'XX-Device-Type':'wxapp'
}
app.post(url, params,header).then((res) => {
console.log(res);
console.log(res.member_intro)
wxParse.wxParse('content', 'html', res.member_intro, that, 5);
}).catch((err) => {
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
... ...
{
"navigationBarTitleText": "会员说明"
}
\ No newline at end of file
... ...
<!--pages/explain/explain.wxml-->
<import src="../../wxParse/wxParse.wxml" />
<view class='explain'>
<template is='wxParse' data='{{wxParseData:content.nodes}}'/>
</view>
\ No newline at end of file
... ...
/* pages/explain/explain.wxss */
page{
background: #FCFEFF;
}
.explain{
margin: 30rpx 32rpx;
box-shadow:0rpx 1rpx 10rpx 0rpx rgba(73,73,73,0.1);
border-radius:10rpx;
padding:40rpx 39rpx 45rpx 39rpx;
color:#333;
font-size: 30rpx;
}
.explain_title{
font-weight: bold;
margin: 0 0 42rpx 0;
}
.explain_item{
margin: 0 0 60rpx 0;
display: flex;
align-items: flex-start;
}
.explain_item_left{
width:25%;
}
.explain_item_rigth{
width:75%;
}
.explain_center{
text-align: center;
font-size:24rpx;
}
.wxParse-p{
display:flex;
justify-content: center;
align-items: center
}
\ No newline at end of file
... ...
// pages/imgscale/imgscale.js
var imageUtil = require('../../utils/util.js');
Page({
/**
* 页面的初始数据
*/
data: {
imagefirstsrc: 'http://bpic.588ku.com/back_pic/00/03/85/1656205138bbe2d.png',//图片链接
imagesecondsrc: 'http://bpic.588ku.com/back_pic/04/07/63/28581203949ca9d.jpg!/fw/400/quality/90/unsharp/true/compress/true',//图片链接
imagethirdsrc: 'http://img1.gtimg.com/ent/pics/hv1/13/71/2061/134034643.jpg',
imagewidth: 0,//缩放后的宽
imageheight: 0,//缩放后的高
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
imageLoad: function (e) {
var imageSize = imageUtil.imageUtil(e)
this.setData({
imagewidth: imageSize.imageWidth,
imageheight: imageSize.imageHeight
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--index.wxml-->
<!--图片宽大于屏幕宽-->
<image style="width: {{imagewidth}}px; height: {{imageheight}}px;" src="{{imagefirstsrc}}" bindload="imageLoad"></image>
<!--图片高大于屏幕高-->
<!--<image style="width: {{imagewidth}}px; height: {{imageheight}}px;" src="{{imagesecondsrc}}" bindload="imageLoad"></image>-->
<!--图片宽高大于屏幕宽高-->
<!--<image style="width: {{imagewidth}}px; height: {{imageheight}}px;" src="{{imagethirdsrc}}" bindload="imageLoad"></image>-->
... ...
/* pages/imgscale/imgscale.wxss */
\ No newline at end of file
... ...
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
url:''
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
this.setData({
url: app.globalData.baseUrl
})
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
})
}
})
}
},
start(e) {
console.log(e)
let that = this;
app.globalData.userInfo = e.detail.userInfo
wx.login({
success: (res) => {
console.log(res)
var url = '/home/Auth/auth';
var params = {
code: res.code,
user_nickname: e.detail.userInfo.nickName,
avatar: e.detail.userInfo.avatarUrl,
}
app.post(url, params).then((res) => {
console.log(res);
wx.setStorageSync('token', res.token)
if (res.is_submit==1){
wx.switchTab({
url: '../pocketlesson/pocketlesson',
})
}else{
wx.navigateTo({
url: "/pages/questionsurvey/questionsurvey",
})
}
}).catch((err) => {
})
}
});
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})
... ...
{
"navigationBarTitleText": "口袋宇宙"
}
\ No newline at end of file
... ...
<!--index.wxml-->
<view class="pagebox">
<image src="http://qiniu.glocalize-asia.com/bk1.png"></image>
<view class="logoimg">
<image src="http://qiniu.glocalize-asia.com/logo.png"></image>
</view>
</view>
<button open-type="getUserInfo" bindgetuserinfo='start' class="start">立即开启</button>
<!-- <button open-type="getUserInfo" bindgetuserinfo='start' class="start">立即开启</button> -->
... ...
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.userinfo-nickname {
color: #aaa;
}
.usermotto {
margin-top: 200px;
}
page{
background: url('http://pnb2waalt.bkt.clouddn.com/bg.png') no-repeat;
background-size: 100% 100%;
}
.pagebox{
width:599rpx;
height:486rpx;
font-size: 0;
margin: 286rpx auto 0;
box-shadow:0px 8px 80px 0px rgba(45,60,75,0.12);
border-radius:20rpx;
position: relative
}
.pagebox image{
width:100%;
height:100%;
border-radius:20rpx;
}
.logoimg{
width:242rpx;
height:264rpx;
font-size: 0;
position: absolute;
top:-88rpx;
left:0;
right:0;
margin: 0 auto;
}
.logoimg image{
width:100%;
height:100%;
}
.start{
width:302rpx;
height:80rpx;
background:linear-gradient(0deg,rgba(1,79,155,1),rgba(6,58,108,1));
box-shadow:0rpx 10rpx 20rpx 0rpx rgba(6,58,108,0.28);
border-radius:40rpx;
margin-top: 210rpx;
color:#FFFFFF;
font-size: 32rpx;
}
\ No newline at end of file
... ...
// pages/kind/kind.js
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
navbar: '',
currentTab: 0,
imgUrls: [
'http://bronet.wangshuwen.com/kliuytyt@2x.png',
'http://bronet.wangshuwen.com/kliuytyt@2x.png',
'http://bronet.wangshuwen.com/kliuytyt@2x.png'
],
indicatorDots: false,
autoplay: false,
interval: 2000,
duration: 1000,
currentSwiper: 0,
parent_id:'',
kindlist:'',
allkindlist:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
//只显示4条数据
getkindlist(){
let that = this;
var url = '/home/Classify/index';
var params = {
parent_id: that.data.parent_id
}
app.post(url, params).then((res) => {
console.log(res)
for (var obj of res.son_classify){
console.log(obj)
obj.grandson_classify = obj.grandson_classify.splice(0,4);
obj.is_more=false
}
that.setData({
kindlist:res,
imgUrls:res.slide,
navbar: res.parent_classify
})
console.log(that.data.kindlist)
}).catch((err) => {
})
},
//展示所有的数据
getallkindlist(){
let that = this;
var url = '/home/Classify/index';
var params = {
parent_id: that.data.parent_id
}
app.post(url, params).then((res) => {
console.log(res);
// var arr=[1,2,3,4,5]
// arr=arr.splice(0,3);
// console.log(arr)
for (var obj of res.son_classify) {
obj.is_more = false
}
that.setData({
allkindlist: res,
imgUrls: res.slide,
navbar: res.parent_classify
})
}).catch((err) => {
})
},
seemore(e){
let that=this;
console.log(e);
that.getallkindlist();
let idx = e.currentTarget.dataset.seeid;
console.log(idx);
let newkindlist = that.data.allkindlist;
console.log(newkindlist);
for (var i=0;i<newkindlist.son_classify.length;i++){
if(i==idx){
let len = newkindlist.son_classify[i].grandson_classify.length;
console.log(len)
newkindlist.son_classify[i].grandson_classify = newkindlist.son_classify[i].grandson_classify.splice(0,len);
console.log(newkindlist.son_classify[i].grandson_classify)
newkindlist.son_classify[i].is_more=true
}else{
newkindlist.son_classify[i].grandson_classify = newkindlist.son_classify[i].grandson_classify.splice(0, 4);
}
}
that.setData({
kindlist:newkindlist
})
console.log(that.data.kindlist);
},
hidemore(e){
let that = this;
that.getkindlist();
let idx = e.currentTarget.dataset.seeid;
let newkindlist = that.data.allkindlist;
console.log(newkindlist)
for (var i = 0; i < newkindlist.son_classify.length;i++) {
if (i == idx) {
let len = newkindlist.son_classify[i].grandson_classify.length;
newkindlist.son_classify[i].grandson_classify = newkindlist.son_classify[i].grandson_classify.splice(0,len);
newkindlist.son_classify[i].is_more = false
}
}
that.setData({
kindlist: newkindlist
})
console.log(that.data.kindlist)
},
swiperChange: function (e) {
this.setData({
currentSwiper: e.detail.current
})
},
//进入详情页
detail(e){
let id = e.currentTarget.dataset.id;
console.log(id)
// let free = e.currentTarget.dataset.free;
wx.navigateTo({
url: '../teachplan/teachplanlist/teachplanlist?id='+id,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
navbarTap: function (e) {
this.setData({
currentTab: e.currentTarget.dataset.idx,
parent_id: e.currentTarget.dataset.id,
})
this.getkindlist();
this.getallkindlist()
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getkindlist();
this.getallkindlist()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
... ...
{
"navigationBarTitleText": "分类"
}
\ No newline at end of file
... ...
<view class="kindnav">
<view wx:for="{{navbar}}" data-idx="{{index}}" class="kindnav_item {{currentTab==index ? 'kindactive' : ''}}" wx:key="unique" bindtap="navbarTap" data-id="{{item.id}}">{{item.category_name}}
</view>
</view>
<view class="swiper_image">
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" class="swiper_item_img" bindchange="swiperChange">
<block wx:for="{{imgUrls}}" wx:key="doct">
<swiper-item>
<image src="{{item.image}}" class="slide-image" width="355" height="150" />
</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="nodata" wx:if="{{kindlist.son_classify.length==0}}">暂无数据</view>
<view class="seconlist" wx:else>
<view class="seconlistitem" wx:for="{{kindlist.son_classify}}" wx:key="">
<view class="kindname">
<view class="kindimg">
<image src="http://bronet.wangshuwen.com/hgkjtyurur@2x.png"></image>
</view>
<view class="kindtypename">{{item.category_name}}</view>
<view class="kindimg">
<image src="http://bronet.wangshuwen.com/hgkjtyurur@2x.png"></image>
</view>
</view>
<view class="nodata" wx:if="{{item.grandson_classify.length==0}}">暂无数据</view>
<block wx:else>
<view class="kindlist">
<view class="kindlistitem" wx:for="{{item.grandson_classify}}" wx:key="" data-id="{{item.id}}" data-free="{{item.goods_price}}" data-id="{{item.id}}" bindtap="detail">
<view class="kindlistitemimg">
<image mode="widthFix" src="{{item.logo}}"></image>
</view>
<view class="kindlistitemnaem">{{item.category_name}}</view>
</view>
</view>
</block>
<view wx:if="{{item.is_more==false}}">
<view class="kindseemore" data-seeid="{{index}}" bindtap="seemore">
<image src="http://bronet.wangshuwen.com/hjktyut@2x.png"></image>
<view class="kindmoreword">查看更多</view>
<view class="kindlowrow">
<image src="http://bronet.wangshuwen.com/ioytrew@2x.png"></image>
</view>
</view>
</view>
<view wx:if="{{item.is_more==true}}">
<view class="kindseemore" data-seeid="{{index}}" bindtap="hidemore">
<image src="http://bronet.wangshuwen.com/hjktyut@2x.png"></image>
<view class="hiderow">
<image src="http://bronet.wangshuwen.com/toprow.png"></image>
</view>
<view class="hide">收起</view>
</view>
</view>
</view>
<!--
<view class="kindname">
<view class="kindimg">
<image src=http://bronet.wangshuwen.com/hgkjtyurur@2x.png"></image>
</view>
<view class="kindtypename">二级分类名称</view>
<view class="kindimg">
<image src=http://bronet.wangshuwen.com/hgkjtyurur@2x.png"></image>
</view>
</view>
<view class="kindlist">
<view class="kindlistitem">
<view class="kindlistitemimg">
<image src=http://bronet.wangshuwen.com/dfsddfhgf@2x.png"></image>
</view>
<view class="kindlistitemnaem">Alphabet</view>
</view>
<view class="kindlistitem">
<view class="kindlistitemimg">
<image src=http://bronet.wangshuwen.com/dfsddfhgf@2x.png"></image>
</view>
<view class="kindlistitemnaem">Alphabet</view>
</view>
<view class="kindlistitem">
<view class="kindlistitemimg">
<image src=http://bronet.wangshuwen.com/dfsddfhgf@2x.png"></image>
</view>
<view class="kindlistitemnaem">Alphabet</view>
</view>
<view class="kindlistitem">
<view class="kindlistitemimg">
<image src=http://bronet.wangshuwen.com/dfsddfhgf@2x.png"></image>
</view>
<view class="kindlistitemnaem">Alphabet</view>
</view>
</view>
<view>
<view class="kindseemore">
<image src=http://bronet.wangshuwen.com/hjktyut@2x.png"></image>
<view class="hiderow">
<image src=http://bronet.wangshuwen.com/toprow.png"></image>
</view>
<view class="hide">收起</view>
</view>
</view> -->
</view>
... ...
@import '../pocketlesson/pocketlesson.wxss';
.kindnav{
height:80rpx;
display:flex;
justify-content:space-between;
text-align:center;
white-space:nowrap;
overflow-x:scroll;
align-items:center;
background:#fff;
font-size:0;
border-bottom:2rpx solid #f5f5f5;
padding:0 32rpx;
}
.kindnav_item {
white-space:nowrap;
list-style:none;
font-size:28rpx;
color:#8D8D8D;
width:auto;
padding:0 36rpx;
position:relative;
}
.kindactive {
color:#007AFF;
}
.kindactive:after{
display:block;
content:"";
width:70rpx;
height:2rpx;
background: #007AFF;
position: absolute;
bottom:-20rpx;
left:0;
right:0;
margin: 0 auto;
}
.kindname{
display:flex;
justify-content: center;
align-items: center;
padding: 24rpx 0 0;
border-top:1rpx solid #f5f5f5;
}
.kindimg{
width:32rpx;
height:26rpx;
font-size: 0;
}
.kindimg image{
width:100%;
height:100%;
}
.kindtypename{
color:#333333;
font-size: 34rpx;
padding: 0 34rpx;
font-weight: bold;
}
.kindlist{
display:flex;
align-items: center;
padding:0 32rpx;
flex-wrap: wrap;
}
.kindlistitem{
width:326rpx;
/* height:250rpx; */
margin-top: 23rpx;
border:1rpx solid#f5f5f5;
padding: 19rpx 0;
box-shadow:0px 1px 4px 0px rgba(64,64,64,0.11);
}
.kindlistitemimg{
width:290rpx;
/* height:196rpx; */
max-height: 196rpx;
overflow: hidden;
font-size: 0;
margin: 0 auto;
}
.kindlistitemimg image{
width:100%;
}
.kindlistitemnaem{
width:290rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color:#333333;
font-size: 32rpx;
/* text-align: center; */
margin: 14rpx auto 0;
}
.kindlistitem:nth-child(2n){
margin-left: 26rpx;
}
.kindseemore{
width:180rpx;
height:105rpx;
font-size: 0;
margin: 10rpx auto 25rpx;
position: relative;
}
.kindseemore image{
width:100%;
height:100%;
}
.kindmoreword{
color:#333333;
font-size: 28rpx;
position: absolute;
top:12rpx;
left:0;
right:0;
text-align: center;
}
.kindlowrow{
width:58rpx;
height:22rpx;
font-size: 0;
position: absolute;
top:56rpx;
bottom:12rpx;
left:0;
right:0;
margin: 0 auto;
}
.kindlowrow image{
width:100%;
height:100%;
}
.hiderow{
width:58rpx;
height:22rpx;
font-size: 0;
position: absolute;
top:12rpx;
left:0;
right:0;
margin: 0 auto;
}
.hide{
color:#333333;
font-size: 28rpx;
position: absolute;
top:42rpx;
bottom:12rpx;
left:0;
right:0;
margin: 0 auto;
text-align: center;
}
... ...
//logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad: function () {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return util.formatTime(new Date(log))
})
})
}
})
... ...
{
"navigationBarTitleText": "查看启动日志"
}
\ No newline at end of file
... ...
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log}}</text>
</block>
</view>
... ...
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
... ...
// pages/member_center/member_center.js
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
memberinfo:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.gethuiyuanstate()
},
gethuiyuanstate(){
let that = this;
var url = '/home/Center/userInfo';
var params = {
}
var header={
'XX-Token': wx.getStorageSync('token'),
'XX-Device-Type':'wxapp'
}
app.post(url, params,header).then((res) => {
console.log(res);
that.setData({
memberinfo:res
})
}).catch((err) => {
})
},
historygo(){
wx.navigateTo({
url: '../pay_record/pay_record',
})
},
//会员说明
state(){
wx.navigateTo({
url: '../explain/explain',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
... ...
{
"navigationBarTitleText": "会员中心"
}
\ No newline at end of file
... ...
<!--pages/member_center/member_center.wxml-->
<view class='center'>
<view class='center_title'>我的会员信息:</view>
<view class='huiguan'>
<view class='huiyuan_icon'>
<image src='http://bronet.wangshuwen.com/asdafds@2x.png'></image>
</view>
<view>{{memberinfo.level}}</view>
</view>
<view class='center_line'>
<view class='center_line_active' style="width:{{memberinfo.bar_percent}}"></view>
</view>
<view class="memberlist">
<text class="membercost">您的当月累计消费:</text>
<text class="membermoney">¥{{memberinfo.monthly_sales}}</text>
<text class="membercost">,</text>
<text class="membercost" style="margin-left:10rpx;">距离升级下一级还差</text>
<text class="membermoney">¥{{memberinfo.short}}</text>
</view>
</view>
<view class='center_item' bindtap="historygo">
<view>购买历史</view>
<view class='iconfont icon-tiaozhuanqianwangyoujiantouxiangyouxiayibuxianxing'></view>
</view>
<view class='center_item' bindtap="state">
<view>会员说明</view>
<view class='iconfont icon-tiaozhuanqianwangyoujiantouxiangyouxiayibuxianxing'></view>
</view>
... ...
/* pages/member_center/member_center.wxss */
page{
background: #FCFEFF;
}
.center{
margin: 70rpx 32rpx 18rpx 32rpx;
padding:40rpx 20rpx 30rpx 20rpx;
background:linear-gradient(90deg,rgba(245,249,255,1),rgba(249,252,255,1));
box-shadow:0rpx 1rpx 24rpx 0rpx rgba(73,73,73,0.12);
border-radius:10rpx;
}
.center_title{
color:#333;
font-size:30rpx;
font-weight: bold;
}
.huiyuan_icon{
margin: 0 12rpx 0 0;
width:33rpx;
height:26rpx;
display: flex;
align-items: center;
justify-content: center;
}
.huiyuan_icon image{
width:100%;
height: 100%;
display: block;
}
.huiguan{
display: flex;
align-items: center;
justify-content: center;
color:#E2C8B1;
font-weight: bold;
font-size:24rpx;
}
.center_line{
position: relative;
margin: 30rpx 0 30rpx 0;
height: 4rpx;
background: #fff;
border:1rpx solid #f8f8f8;
border-radius: 2rpx;
/* overflow: hidden; */
}
.center_line_active{
position: absolute;
top:50%;
height: 3rpx;
transform: translateY(-50%);
background: #1C5A97;
border-radius: 2rpx -2rpx -2rpx 2rpx;
width:30%;
left:0;
z-index:10;
}
.center_item{
display: flex;
align-items: center;
justify-content:space-between;
padding:33rpx 0;
margin: 0 32rpx;
background: #fff;
border-radius: 8rpx;
color:#333;
font-size:30rpx;
font-weight: bold;
border-bottom:1rpx solid #E8E8E8;
}
.center_item:last-child{
border-bottom:none;
}
.membercost{
color:#333333;
font-size:24rpx;
}
.membermoney{
color:#FF8080;
font-size: 24rpx;
}
.memberlist{
/* margin-top:20rpx; */
}
\ No newline at end of file
... ...
// pages/mine/mine.js
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
myindexinfo:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getmyindex()
},
getmyindex(){
let that = this;
var url = '/home/Center/index';
var params = {
}
var header={
'XX-Token': wx.getStorageSync('token'),
'XX-Device-Type':'wxapp'
}
app.post(url, params,header).then((res) => {
console.log(res);
that.setData({
myindexinfo:res
})
}).catch((err) => {
})
},
enterquestion(){
wx.navigateTo({
url: '../questionsurvey/questionsurvey',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
... ...
{
"navigationBarTitleText": "我的"
}
\ No newline at end of file
... ...
<!--pages/mine/mine.wxml-->
<view class='mine'>
<image src='http://qiniu.glocalize-asia.com/lastmy.png'></image>
</view>
<view class='mine_main'>
<view class='head'>
<image src='{{myindexinfo.avatar}}'></image>
</view>
<view class='mine_top'>
<view>{{myindexinfo.user_nickname}}</view>
<view class='mine_rigth' bindtap="enterquestion">
<view>问卷调查</view>
<view class='iconfont icon-tiaozhuanqianwangyoujiantouxiangyouxiayibuxianxing'></view>
</view>
</view>
<view class='huiyuan'>
<view class='huiyuan_icon'>
<image src='http://qiniu.glocalize-asia.com/asdafds@2x.png'></image>
</view>
<view>{{myindexinfo.level}}</view>
</view>
<view class='line'></view>
<navigator class='mine_item' url='/pages/member_center/member_center' hover-class="none">
<view>会员中心</view>
<view class='iconfont icon-tiaozhuanqianwangyoujiantouxiangyouxiayibuxianxing'></view>
</navigator>
<navigator class='mine_item' url='/pages/download/download' hover-class="none">
<view>我的下载</view>
<view class='iconfont icon-tiaozhuanqianwangyoujiantouxiangyouxiayibuxianxing'></view>
</navigator>
<navigator class='mine_item' url='/pages/my_collect/my_collect' hover-class="none">
<view>我的收藏</view>
<view class='iconfont icon-tiaozhuanqianwangyoujiantouxiangyouxiayibuxianxing'></view>
</navigator>
<navigator class='mine_item' url='/pages/aboutme/aboutme' hover-class="none">
<view>关于我们</view>
<view class='iconfont icon-tiaozhuanqianwangyoujiantouxiangyouxiayibuxianxing'></view>
</navigator>
</view>
\ No newline at end of file
... ...
/* pages/mine/mine.wxss */
page {
/* background: #d3dfe8; */
height:100%;
/* background: url("http://pnb2waalt.bkt.clouddn.com/lastmy.png")no-repeat center;
background-size: 100%,100%; */
}
.mine {
height:100%;
/* position: fixed;
top: 0;
left: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%; */
}
.mine image{
display: block;
width:100%;
height: 100%;
}
.mine_main{
position: absolute;
left:0;
right:0;
bottom:0;
margin: 0 auto;
z-index:2;
width:686rpx;
color:#333;
font-size:26rpx;
background: #fff;
border-radius: 13rpx 13rpx 0 0;
}
.mine_main .head{
position: absolute;
z-index:3;
left:76rpx;
top:-90rpx;
width:130rpx;
height: 130rpx;
font-size: 0;
border-radius: 50%;
}
.head image{
width:100%;
height:100%;
border-radius: 50%;
}
.mine_top{
margin: 59rpx 42rpx 22rpx 76rpx;
color:#333333;
font-size:30rpx;
font-weight: bold;
display: flex;
align-items: center;
justify-content: space-between;
}
.mine_rigth{
font-weight: normal;
display: flex;
align-items: center;
color:#999;
font-size:24rpx;
}
.mine_rigth .iconfont{
margin: 0 0 0 5rpx;
}
.huiyuan{
margin: 0 0 37rpx 0;
display: flex;
align-items: center;
justify-content: center;
border-radius:0 25rpx 25rpx 0;
width:240rpx;
height: 50rpx;
color:#fff;
background: linear-gradient(to right, #318AE2 , #57ABFF);
box-shadow: 0 0 10rpx #8BC2FA;
}
.huiyuan_icon{
margin: 0 12rpx 0 0;
width:33rpx;
height:26rpx;
display: flex;
align-items: center;
justify-content: center;
}
.huiyuan_icon image{
width:100%;
height: 100%;
display: block;
}
.line{
margin: 0 27rpx 0 13rpx;
background: rgba(36, 35, 35, 0.7);
height:2rpx;
}
.mine_item{
margin: 0 42rpx 0 47rpx;
padding:27rpx 0 24rpx 0;
border-bottom: 1rpx solid #E8E8E8;
display: flex;
align-items: center;
justify-content: space-between;
color:#333;
font-weight: bold;
font-size: 32rpx;
}
.mine_item:last-child{
border-bottom:none;
}
\ No newline at end of file
... ...