作者 徐浩

初始化厂库

要显示太多修改。

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

unpackage/
node_modules/
package.json/
package-lock.json/
common/service.js
/.hbuilderx
/unpackage
\ No newline at end of file
... ...
<script>
import Vue from 'vue'
import {
mapState,
mapMutations
} from 'vuex'
var that
export default {
onLaunch: function() {
that=this
console.log('App Launch')
var token=uni.getStorageSync('token')
// if(token){
// var identity=uni.getStorageSync('identity')
// if(identity==2){
// uni.reLaunch({
// url:'/pages/tch_index/tch_index'
// })
// }else if(identity==1){
// uni.switchTab({
// url:'/pages/index/index'
// })
// } else {
// uni.reLaunch({
// url:'/pages/admin_index/admin_index'
// })
// }
// }
uni.getSystemInfo({
success: function(e) {
that.$store.commit('setplatform',e.platform)
// #ifndef MP
Vue.prototype.StatusBar = e.statusBarHeight;
if (e.platform == 'android') {
Vue.prototype.CustomBar = e.statusBarHeight + 50;
} else {
Vue.prototype.CustomBar = e.statusBarHeight + 45;
};
// #endif
// #ifdef MP-WEIXIN
Vue.prototype.StatusBar = e.statusBarHeight;
let custom = wx.getMenuButtonBoundingClientRect();
Vue.prototype.Custom = custom;
Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
// #endif
// #ifdef MP-ALIPAY
Vue.prototype.StatusBar = e.statusBarHeight;
Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
// #endif
}
})
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
</script>
<style>
/* @import "@/uni_modules/uview-ui/index.scss"; */
@import "./static/iconfont.css";
/* @font-face {
font-style: normal;
font-family: DINCond-Bold;
src: url("/static/font/DINCond-Bold.otf");
}
@font-face {
font-style: normal;
font-family: PingFang SC;
src: url("/static/font/PingFang Medium.ttf");
} */
/*每个页面公共css */
uni-page-body,
html,
body {
margin: 0;
font-family: PingFang SC, DINCond-Bold, '微软雅黑';
background-color: #F8F8F8;
box-sizing: border-box;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
letter-spacing: 2rpx;
}
view,
text,
input {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
button {
margin: 0;
padding: 0;
}
button::after {
border: none;
margin: 0;
padding: 0;
}
.flex {
display: flex;
display: -webkit-box;
display: -moz-box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
}
.area {
width: 694rpx !important;
box-sizing: border-box;
margin: 0 auto;
}
.bottom-of-page {
position: relative;
padding-bottom: 160rpx;
padding-bottom: calc(160rpx + constant(safe-area-inset-bottom));
padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
}
.spot {
width: 14rpx;
height: 14rpx;
background: #2D81FF;
border-radius: 50%;
}
.bottom-button {
/* 底部按钮 */
box-shadow: 0rpx 4rpx 21rpx 3rpx rgba(153, 153, 153, 0.12);
position: fixed;
bottom: 0;
left: 0;
justify-content: center;
align-items: center;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
}
.uni-input {
color: #333333;
font-size: 26rpx;
}
.header-wrap {
/* 头部背景色 */
width: 100%;
min-height: 260rpx;
background: linear-gradient(0deg, #f8f8f8 0%, #ffffff 25%, #5D9DFD 60%, #428EFE 70%, #2D81FF 100%);
position: relative;
padding-top: 20rpx;
}
.content-wrap {
position: absolute;
top: 28rpx;
left: 50%;
transform: translate(-50%, 0);
}
.text-single {
/* 单行文本显示省略号*/
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.text-retain {
/* 多行文本保留两行 */
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
*{
box-sizing:border-box;
}
view,text{
box-sizing:border-box;
letter-spacing: 0;
}
.fwb{
font-weight: bold;
font-family: PingFang SC, '微软雅黑';
}
/*每个页面公共css */
.content {
background: #f8f8f8;
font-family: "微软雅黑";
}
.dis_flex {
/* #ifndef APP-PLUS-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.dis_flex_c {
/* #ifndef APP-PLUS-NVUE */
display: flex;
/* #endif */
flex-direction: column;
}
.fww {
flex-wrap: wrap;
}
.aic {
align-items: center;
}
.ais {
align-items: stretch !important;
}
.aift {
align-items: flex-start;
}
.aife {
align-items: flex-end;
}
.ju_a {
justify-content: space-around;
}
.ju_b {
justify-content: space-between;
}
.ju_c {
justify-content: center;
}
.flex_1 {
flex: 1;
}
.flex_0 {
flex: none;
}
.oh1 {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box !important;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
// text-align: center;
}
.oh2 {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
view {
word-break: break-all;
word-wrap: break-word;
}
.oh3 {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
.oh4 {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
}
.scroll_x {
width: 100%;
white-space: nowrap;
}
.textarea-uni{
font-size: 32rpx;
}
</style>
... ...
/**
* [js-md5]{@link https://github.com/emn178/js-md5}
*
* @namespace md5
* @version 0.7.3
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2017
* @license MIT
*/
!function(){"use strict";function t(t){if(t)d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d,this.buffer8=l;else if(a){var r=new ArrayBuffer(68);this.buffer8=new Uint8Array(r),this.blocks=new Uint32Array(r)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}var r="input is invalid type",e="object"==typeof window,i=e?window:{};i.JS_MD5_NO_WINDOW&&(e=!1);var s=!e&&"object"==typeof self,h=!i.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;h?i=global:s&&(i=self);var f=!i.JS_MD5_NO_COMMON_JS&&"object"==typeof module&&module.exports,o="function"==typeof define&&define.amd,a=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,n="0123456789abcdef".split(""),u=[128,32768,8388608,-2147483648],y=[0,8,16,24],c=["hex","array","digest","buffer","arrayBuffer","base64"],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[],l;if(a){var A=new ArrayBuffer(68);l=new Uint8Array(A),d=new Uint32Array(A)}!i.JS_MD5_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!a||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var b=function(r){return function(e){return new t(!0).update(e)[r]()}},v=function(){var r=b("hex");h&&(r=w(r)),r.create=function(){return new t},r.update=function(t){return r.create().update(t)};for(var e=0;e<c.length;++e){var i=c[e];r[i]=b(i)}return r},w=function(t){var e=eval("require('crypto')"),i=eval("require('buffer').Buffer"),s=function(s){if("string"==typeof s)return e.createHash("md5").update(s,"utf8").digest("hex");if(null===s||void 0===s)throw r;return s.constructor===ArrayBuffer&&(s=new Uint8Array(s)),Array.isArray(s)||ArrayBuffer.isView(s)||s.constructor===i?e.createHash("md5").update(new i(s)).digest("hex"):t(s)};return s};t.prototype.update=function(t){if(!this.finalized){var e,i=typeof t;if("string"!==i){if("object"!==i)throw r;if(null===t)throw r;if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw r;e=!0}for(var s,h,f=0,o=t.length,n=this.blocks,u=this.buffer8;f<o;){if(this.hashed&&(this.hashed=!1,n[0]=n[16],n[16]=n[1]=n[2]=n[3]=n[4]=n[5]=n[6]=n[7]=n[8]=n[9]=n[10]=n[11]=n[12]=n[13]=n[14]=n[15]=0),e)if(a)for(h=this.start;f<o&&h<64;++f)u[h++]=t[f];else for(h=this.start;f<o&&h<64;++f)n[h>>2]|=t[f]<<y[3&h++];else if(a)for(h=this.start;f<o&&h<64;++f)(s=t.charCodeAt(f))<128?u[h++]=s:s<2048?(u[h++]=192|s>>6,u[h++]=128|63&s):s<55296||s>=57344?(u[h++]=224|s>>12,u[h++]=128|s>>6&63,u[h++]=128|63&s):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++f)),u[h++]=240|s>>18,u[h++]=128|s>>12&63,u[h++]=128|s>>6&63,u[h++]=128|63&s);else for(h=this.start;f<o&&h<64;++f)(s=t.charCodeAt(f))<128?n[h>>2]|=s<<y[3&h++]:s<2048?(n[h>>2]|=(192|s>>6)<<y[3&h++],n[h>>2]|=(128|63&s)<<y[3&h++]):s<55296||s>=57344?(n[h>>2]|=(224|s>>12)<<y[3&h++],n[h>>2]|=(128|s>>6&63)<<y[3&h++],n[h>>2]|=(128|63&s)<<y[3&h++]):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++f)),n[h>>2]|=(240|s>>18)<<y[3&h++],n[h>>2]|=(128|s>>12&63)<<y[3&h++],n[h>>2]|=(128|s>>6&63)<<y[3&h++],n[h>>2]|=(128|63&s)<<y[3&h++]);this.lastByteIndex=h,this.bytes+=h-this.start,h>=64?(this.start=h-64,this.hash(),this.hashed=!0):this.start=h}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>2]|=u[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},t.prototype.hash=function(){var t,r,e,i,s,h,f=this.blocks;this.first?r=((r=((t=((t=f[0]-680876937)<<7|t>>>25)-271733879<<0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+f[1]-117830708)<<12|i>>>20)+t<<0)&(-271733879^t))+f[2]-1126478375)<<17|e>>>15)+i<<0)&(i^t))+f[3]-1316259209)<<22|r>>>10)+e<<0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+f[0]-680876936)<<7|t>>>25)+r<<0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+f[1]-389564586)<<12|i>>>20)+t<<0)&(t^r))+f[2]+606105819)<<17|e>>>15)+i<<0)&(i^t))+f[3]-1044525330)<<22|r>>>10)+e<<0),r=((r+=((t=((t+=(i^r&(e^i))+f[4]-176418897)<<7|t>>>25)+r<<0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+f[5]+1200080426)<<12|i>>>20)+t<<0)&(t^r))+f[6]-1473231341)<<17|e>>>15)+i<<0)&(i^t))+f[7]-45705983)<<22|r>>>10)+e<<0,r=((r+=((t=((t+=(i^r&(e^i))+f[8]+1770035416)<<7|t>>>25)+r<<0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+f[9]-1958414417)<<12|i>>>20)+t<<0)&(t^r))+f[10]-42063)<<17|e>>>15)+i<<0)&(i^t))+f[11]-1990404162)<<22|r>>>10)+e<<0,r=((r+=((t=((t+=(i^r&(e^i))+f[12]+1804603682)<<7|t>>>25)+r<<0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+f[13]-40341101)<<12|i>>>20)+t<<0)&(t^r))+f[14]-1502002290)<<17|e>>>15)+i<<0)&(i^t))+f[15]+1236535329)<<22|r>>>10)+e<<0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+f[1]-165796510)<<5|t>>>27)+r<<0)^r))+f[6]-1069501632)<<9|i>>>23)+t<<0)^t&((e=((e+=(t^r&(i^t))+f[11]+643717713)<<14|e>>>18)+i<<0)^i))+f[0]-373897302)<<20|r>>>12)+e<<0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+f[5]-701558691)<<5|t>>>27)+r<<0)^r))+f[10]+38016083)<<9|i>>>23)+t<<0)^t&((e=((e+=(t^r&(i^t))+f[15]-660478335)<<14|e>>>18)+i<<0)^i))+f[4]-405537848)<<20|r>>>12)+e<<0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+f[9]+568446438)<<5|t>>>27)+r<<0)^r))+f[14]-1019803690)<<9|i>>>23)+t<<0)^t&((e=((e+=(t^r&(i^t))+f[3]-187363961)<<14|e>>>18)+i<<0)^i))+f[8]+1163531501)<<20|r>>>12)+e<<0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+f[13]-1444681467)<<5|t>>>27)+r<<0)^r))+f[2]-51403784)<<9|i>>>23)+t<<0)^t&((e=((e+=(t^r&(i^t))+f[7]+1735328473)<<14|e>>>18)+i<<0)^i))+f[12]-1926607734)<<20|r>>>12)+e<<0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+f[5]-378558)<<4|t>>>28)+r<<0))+f[8]-2022574463)<<11|i>>>21)+t<<0)^t)^(e=((e+=(h^r)+f[11]+1839030562)<<16|e>>>16)+i<<0))+f[14]-35309556)<<23|r>>>9)+e<<0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+f[1]-1530992060)<<4|t>>>28)+r<<0))+f[4]+1272893353)<<11|i>>>21)+t<<0)^t)^(e=((e+=(h^r)+f[7]-155497632)<<16|e>>>16)+i<<0))+f[10]-1094730640)<<23|r>>>9)+e<<0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+f[13]+681279174)<<4|t>>>28)+r<<0))+f[0]-358537222)<<11|i>>>21)+t<<0)^t)^(e=((e+=(h^r)+f[3]-722521979)<<16|e>>>16)+i<<0))+f[6]+76029189)<<23|r>>>9)+e<<0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+f[9]-640364487)<<4|t>>>28)+r<<0))+f[12]-421815835)<<11|i>>>21)+t<<0)^t)^(e=((e+=(h^r)+f[15]+530742520)<<16|e>>>16)+i<<0))+f[2]-995338651)<<23|r>>>9)+e<<0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+f[0]-198630844)<<6|t>>>26)+r<<0)|~e))+f[7]+1126891415)<<10|i>>>22)+t<<0)^((e=((e+=(t^(i|~r))+f[14]-1416354905)<<15|e>>>17)+i<<0)|~t))+f[5]-57434055)<<21|r>>>11)+e<<0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+f[12]+1700485571)<<6|t>>>26)+r<<0)|~e))+f[3]-1894986606)<<10|i>>>22)+t<<0)^((e=((e+=(t^(i|~r))+f[10]-1051523)<<15|e>>>17)+i<<0)|~t))+f[1]-2054922799)<<21|r>>>11)+e<<0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+f[8]+1873313359)<<6|t>>>26)+r<<0)|~e))+f[15]-30611744)<<10|i>>>22)+t<<0)^((e=((e+=(t^(i|~r))+f[6]-1560198380)<<15|e>>>17)+i<<0)|~t))+f[13]+1309151649)<<21|r>>>11)+e<<0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+f[4]-145523070)<<6|t>>>26)+r<<0)|~e))+f[11]-1120210379)<<10|i>>>22)+t<<0)^((e=((e+=(t^(i|~r))+f[2]+718787259)<<15|e>>>17)+i<<0)|~t))+f[9]-343485551)<<21|r>>>11)+e<<0,this.first?(this.h0=t+1732584193<<0,this.h1=r-271733879<<0,this.h2=e-1732584194<<0,this.h3=i+271733878<<0,this.first=!1):(this.h0=this.h0+t<<0,this.h1=this.h1+r<<0,this.h2=this.h2+e<<0,this.h3=this.h3+i<<0)},t.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return n[t>>4&15]+n[15&t]+n[t>>12&15]+n[t>>8&15]+n[t>>20&15]+n[t>>16&15]+n[t>>28&15]+n[t>>24&15]+n[r>>4&15]+n[15&r]+n[r>>12&15]+n[r>>8&15]+n[r>>20&15]+n[r>>16&15]+n[r>>28&15]+n[r>>24&15]+n[e>>4&15]+n[15&e]+n[e>>12&15]+n[e>>8&15]+n[e>>20&15]+n[e>>16&15]+n[e>>28&15]+n[e>>24&15]+n[i>>4&15]+n[15&i]+n[i>>12&15]+n[i>>8&15]+n[i>>20&15]+n[i>>16&15]+n[i>>28&15]+n[i>>24&15]},t.prototype.toString=t.prototype.hex,t.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>8&255,t>>16&255,t>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255,255&e,e>>8&255,e>>16&255,e>>24&255,255&i,i>>8&255,i>>16&255,i>>24&255]},t.prototype.array=t.prototype.digest,t.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t},t.prototype.buffer=t.prototype.arrayBuffer,t.prototype.base64=function(){for(var t,r,e,i="",s=this.array(),h=0;h<15;)t=s[h++],r=s[h++],e=s[h++],i+=p[t>>>2]+p[63&(t<<4|r>>>4)]+p[63&(r<<2|e>>>6)]+p[63&e];return t=s[h],i+=p[t>>>2]+p[t<<4&63]+"=="};var _=v();f?module.exports=_:(i.md5=_,o&&define(function(){return _}))}();
\ No newline at end of file
... ...
export default{
data(){
return {
//设置默认的分享参数
//如果页面不设置share,就触发这个默认的分享
// share:{
// title:'中志教育',
// path:'/pages/index/index?id='+uni.getStorageSync('parentid'),
// imageUrl:'/static/images/yzxz.png',
// desc:'',
// content:''
// }
}
},
// onShareAppMessage(res) {
// return {
// title:this.share.title,
// path:this.share.path,
// imageUrl:this.share.imageUrl,
// desc:this.share.desc,
// content:this.share.content,
// success(res){
// uni.showToast({
// title:'分享成功'
// })
// },
// fail(res){
// uni.showToast({
// title:'分享失败',
// icon:'none'
// })
// }
// }
// },
// onShareTimeline(res) {//分享到朋友圈
// return {
// title:this.share.title,
// path:this.share.path,
// imageUrl:this.share.imageUrl,
// desc:this.share.desc,
// content:this.share.content,
// success(res){
// uni.showToast({
// title:'分享成功'
// })
// },
// fail(res){
// uni.showToast({
// title:'分享失败',
// icon:'none'
// })
// }
// }
// },
}
\ No newline at end of file
... ...
/**
* 所有封装包的基础方法
*/
import alert from '@/common/sju.alert.js';
import md5 from '@/common/md5.min.js';
let base = {
/**
* @description 开发阶段输出信息(可以随时关闭输出)
* @param {string} msg 要输出的消息
*/
logInfo: function(msg) {
// console.info(msg);
},
/**
* @description 返回md5加密后的结果
* @param {string} val 要加密的数据
*/
toMD5: function(val) {
return md5(val);
},
/**
* @description 判断是否空值,如果是空值,则返回true
* @param {string} val 要判断的数据
*/
isNull: function(val) {
var isNull = false;
if (typeof(val) == undefined)
isNull = true;
if (val == null)
isNull = true;
if (val == "")
isNull = true;
return isNull;
},
/**
* @description 判断是否非空值,如果是非空值,则返回true
* @param {string} val 要判断的数据
*/
isNotNull: function(val) {
return !base.isNull(val);
},
/**
* 检查是否非空,如果非空,返回True,否则返回false,并显示错误提示
* @param {string} val 要判断的数据
* @param {string} msg 空的时候显示的错误提示
*/
checkNotNull: function(val, msg) {
if (base.isNull(val)) {
alert.showError(msg);
return false;
}
return true;
},
/**
* @description 一次检查多个参数是否非空
* <br/>有一个为空则返回false;
* <br/>返回false时,显示为空的错误提醒
* @param {array} arr 要检查的数据描述
* <br/>参数格式: [{val:'xxx',msg:'xxx'},...]
*/
checkArrayNotNull: function(arr) {
var isNotNull = true;
if (typeof(arr) == 'object') {
for (let item of arr) {
if (base.isNull(item.val)) {
isNotNull = false;
alert.showError(item.msg);
break;
}
}
} else {
isNotNull = false;
alert.showError('参数不合法');
}
return isNotNull;
}
}
export default base;
\ No newline at end of file
... ...
/**
* 用户登录状态的相关封装
*/
import ajax from '@/common/sju.ajax.js';
import base from '@/common/sju.base.js';
import sjuNav from '@/common/sju.nav.js'
let login = {
/**
* @description 保存不需要登录的页面路径地址
* /intake/login 用户登录页面
* /intake/register 用户注册页面
* @param {数组}
*/
noLogin: ['/pages/login/login'],
/**
* @description 判断访问的Page是否需要登录
* 如果需要登录, 则判断是否已登录,未登录则跳转到登陆界面
* @param {string} url 打开的页面
*/
checkLogin: function(url) {
// 保存不需要登录的页面,如果pageUrl不在数组中存在,则需要登录
let needLogin = false;
for (let item of login.noLogin) {
if (item == url)
needLogin = false;
}
// 如果需要登录,并且没有登录token标识,则跳转到登陆页面
let token = login.getValue('token');
if (needLogin && base.isNull(token)) {
base.logInfo("需要登录:" + url);
//微信小程序,提供登录提醒
//#ifdef MP-WEIXIN
login.weixinInfo()
//#endif
//其它平台,直接跳转登录
//#ifdef APP-PLUS || H5
sjuNav.redirectTo('/intake/login');
//#endif
} else {
return true;
}
return false;
},
/**
* @description 微信小程序获取用户信息
*/
weixinInfo() {
var that = this
uni.hideLoading();
uni.getUserProfile({
desc: "用于个人中心信息展示",
lang: "zh_CN",
success: res => {
// var rawData = JSON.parse(res.rawData);
// login.weixinLogin(rawData.nickName, rawData.avatarUrl);
// console.log(res);
if (res.errMsg == 'getUserProfile:ok' && res.userInfo !=
undefined) {
var userInfo = {
avatarUrl: res.userInfo.avatarUrl,
nickName: res.userInfo.nickName,
iv: res.iv,
encryptedData: res.encryptedData
}
login.weixinLogin(userInfo);
} else {
uni.showToast({
icon: "none",
title: "获取失败,请重试"
})
}
},
fail: (res) => {
console.info('获取失败')
}
});
},
/**
* @description 微信小程序获取openID
* @param {string} nickName 微信用户名称
* @param {string} avatarUrl 用户用户头像
*/
weixinLogin(userInfo) {
uni.login({
provider: 'weixin',
scopes: 'auth_user',
success: function(loginRes) {
// 获取临时code
var code = loginRes.code;
// 请求后台接口获取openID
ajax.post('/api/Member.Member/miniWxLogin', {
code: code,
encryptedData: userInfo.encryptedData,
iv: userInfo.iv
}, data => {
console.log(data);
}, true)
ajax.post('/api/Member.Member/miniWxCodeRefreshToken', {
code: code
}, data => {
console.log(data);
// if (loginres.statusCode == 200) {
// let token = loginres.data.data.token
// uni.setStorageSync('token',data.token)
// uni.reLaunch({
// url: `/pages/profile/profile?headerUrl=${that.headerUrl}&nickName=${that.nickName}`
// });
// }
// 把后台返回的token保存到本地存储
// login.saveValue('token',data.token);
}, true)
// login.getPhone(userInfo, loginRes)
}
});
},
// 绑定手机号
getPhone(userInfo, loginRes) {
// console.log(userInfo, loginRes);
var code = loginRes.code;
ajax.post('/api/Member.Member/bindMobile', {
code: code,
encryptedData: userInfo.encryptedData,
iv: userInfo.iv
}, res => {
// console.log(res);
})
},
/**
* @description 本地存储
* @param {string} key 保存变量的标识
* @param {any} value 保存的值
*/
saveValue: function(key, value) {
uni.setStorageSync(key, value);
},
/**
* @description 从本地存储获取key数据
* @param {string} key 保存变量的标识
*/
getValue: function(key) {
let value = uni.getStorageSync(key);
return value;
},
/**
* @description 从本地存储清除某个key
* @param {string} key 保存变量的标识
*/
clearKey: function(key) {
uni.removeStorageSync(key);
},
/**
* @description 从本地存储清除所有数据
* @param {string} key 保存变量的标识
*/
clearAll: function(key) {
uni.clearStorageSync();
}
}
export default login;
... ...
// 页面跳转的相关方法
// import base from '@/common/sju.base.js';
// import login from '@/common/sju.login.js'
let nav = {
/**
* @description 保留当前页面,跳转到应用内的某个页面,使用uni.navigateBack可以返回到原页面。
* @param {string} url 跳转的地址
*/
navigateTo: function(url, param = {}) {
if (JSON.stringify(param) !== '{}') {
uni.navigateTo({
url: url += `?param=${JSON.stringify(param)}`
})
} else {
uni.navigateTo({
url: url,
fail(err) {
console.log('navigateTo 失败');
},
})
}
return
// 判断打开页面是否需要登录
if (login.checkLogin(url)) {
// url = tranferUrl(url);//用于判断解析分包
if (JSON.stringify(param) !== '{}') {
uni.navigateTo({
url: url += `?param=${JSON.stringify(param)}`
})
} else {
uni.navigateTo({
url: url,
fail(err) {
console.log('navigateTo 失败');
},
})
}
}
},
/**
* @description 关闭当前页面,跳转到应用内的某个页面。
* @param {sting} url 跳转的地址
* @param {string} para 页面参数
*/
redirectTo: function(url, param = {}) {
if (JSON.stringify(param) !== '{}') {
uni.redirectTo({
url: url += `?param=${JSON.stringify(param)}`
})
} else {
uni.redirectTo({
url: url,
fail(err) {
console.log('redirectTo 失败');
},
})
}
return
// 判断打开页面是否需要登录
if (login.checkLogin(url)) {
// url = tranferUrl(url);//用于判断解析分包
if (JSON.stringify(param) !== '{}') {
uni.redirectTo({
url: url += `?param=${JSON.stringify(param)}`
})
} else {
uni.redirectTo({
url: url,
fail(err) {
console.log('redirectTo 失败');
},
})
}
}
},
/**
* @description 关闭所有页面,打开到应用内的某个页面。
* @param {sting} url 跳转的地址
* @param {string} para 页面参数
*/
reLaunch: function(url, param = {}) {
if (JSON.stringify(param) !== '{}') {
uni.reLaunch({
url: url += `?param=${JSON.stringify(param)}`
})
} else {
uni.reLaunch({
url: url,
fail(err) {
console.log('reLaunch 失败');
},
})
}
return
// 判断打开页面是否需要登录
if (login.checkLogin(url)) {
// url = tranferUrl(url);//用于判断解析分包
if (JSON.stringify(param) !== '{}') {
uni.reLaunch({
url: url += `?param=${JSON.stringify(param)}`
})
} else {
uni.reLaunch({
url: url,
fail(err) {
console.log('reLaunch 失败');
},
})
}
}
},
/**
* @description 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面。
* @param {sting} url 跳转的地址
*/
switchTab: function(url) {
uni.switchTab({
url: url,
fail: function() {
console.log('switchTab 失败')
}
})
return
if (login.checkLogin(url)) {
// url = tranferUrl(url);
uni.switchTab({
url: url,
fail: function() {
console.log('switchTab 失败')
}
})
}
},
/**
* @description 关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages() 获取当前的页面栈,决定需要返回几层。
* @param {number} delta 返回的页面数
*/
navigateBack: function(delta, param = {}) {
if (JSON.stringify(param) !== '{}') {
uni.navigateBack({
delta: delta += `?param=${JSON.stringify(param)}`
})
} else {
uni.navigateBack({
delta: delta
});
}
}
}
export default nav;
... ...
<template>
<view>
<!-- #ifdef MP-WEIXIN -->
<view class="CustomReturn-container" :style="{height: titleHeight, paddingTop: paddingTop, backgroundColor: bgColor}">
<view class="CustomReturn">
<view v-if="isShowBreak" class="CustomReturn-r">
<u-icon name="home" v-if="isFirstPage && !isCustomReturn" @click="toBreak()" size="23" :color="color"></u-icon>
<u-icon name="arrow-left" v-else @click="toBreak()" size="20" :color="color"></u-icon>
</view>
<view style="width: 200rpx;" v-else ></view>
<view class="CustomReturn-title" :style="{'color': color}">{{ title }}</view>
<view style="width: 200rpx;"></view>
</view>
<view class="other">
<slot></slot>
</view>
</view>
<!-- #endif -->
</view>
</template>
<script>
export default {
name:"CustomReturn",
components: {
},
props: {
color: {
type: String,
default: '#000000'
},
isShowOtherIcon: {
type: Boolean,
default: true
},
bgColor: {
type: String,
default: '#fff'
},
breakUrl: {
type: String,
default: ''
},
isShowBreak: {
type: Boolean,
default: true
},
title: {
type: [String, Number],
default: '标题'
},
isCustomReturn: {
type: Boolean,
default: false
}
},
data() {
return {
show: false,
titleHeight: 0,
paddingTop: 0,
otherHeight: 0,
isFirstPage: false,
entityHeight: 0
};
},
mounted() {
this.getHeight()
this.getOther()
this.identifyPages()
},
methods: {
toExamination() {
uni.reLaunch({
url: '/pages/examination/examination'
})
},
toPersonalCenter() {
uni.reLaunch({
url: '/pages/personalCenter/personalCenter'
})
},
// 获取除顶部导航栏以外的高度
getOtherHeight() {
return this.otherHeight
},
getOther() {
uni.createSelectorQuery().in(this).select('.other')
.fields({ size: true }, (res) => {
if (res) {
this.otherHeight = res.height
console.log('元素高度', res.height);
this.$emit('init', {otherHeight: this.otherHeight, entityHeight: this.entityHeight})
}
}).exec();
},
// 辨别页面
identifyPages() {
let result = getCurrentPages()
if(result.length === 1) {
this.isFirstPage = true
} else {
this.isFirstPage = false
}
},
getHeight() {
this.titleHeight = 88 + 'rpx';
this.paddingTop = uni.getSystemInfoSync().statusBarHeight + 'px'
// #ifdef MP-WEIXIN
let res = wx.getMenuButtonBoundingClientRect();
// #endif
this.paddingTop = res.top + 'px'
this.titleHeight = res.height + 10 + 'px';
this.entityHeight = res.top + res.height
},
toBreak(){
if(!this.isCustomReturn) {
let result = getCurrentPages()
if(result.length === 1) {
uni.reLaunch({
url: '/pages/examination/examination'
})
} else {
uni.navigateBack({
delta: 1
})
}
} else {
this.$emit('goBack')
}
}
}
}
</script>
<style lang="scss" scoped>
.CustomReturn-container{
position: fixed;
top: 0;
width: 100%;
z-index: 1002;
transition: all .5s;
box-sizing: content-box;
}
.CustomReturn{
display: flex;
align-items: center;
flex-grow: 1;
padding: 0 24rpx;
justify-content: space-between;
position: relative;
z-index: 1002;
height: 100%;
padding-bottom: 10px;
box-sizing: border-box;
.CustomReturn-title{
font-size: 36rpx;
}
.CustomReturn-r{
display: flex;
width: 200rpx;
align-items: center;
.CustomReturn-i{
height: 36rpx;
width: 36rpx;
margin-left: 30rpx;
}
}
}
</style>
\ No newline at end of file
... ...
<template>
<u-popup :show="show" :safeAreaInsetBottom="false" bgColor="transparent" mode="center">
<view class="HonorWall">
<view class="HonorWall-i">
<u-icon name="close-circle" @click="close" size="30" color="#fff"></u-icon>
</view>
<view class="HonorWall-c">
<image class="HonorWall-c-bg" src="@/static/imagesV2/icon13.png" mode="widthFix"></image>
<view class="HonorWall-c-c">
<view class="HonorWall-c-c-t">
<view class="HonorWall-c-c-t-c">荣誉勋章</view>
</view>
<view class="HonorWall-c-c-b">
<view class="HonorWall-c-c-b-i" v-for="(item, index) in dataList" :key="index">
<image class="HonorWall-c-c-b-i-i"v-if="item.is_light" src="@/static/imagesV2/icon15s.png" mode="widthFix"></image>
<image class="HonorWall-c-c-b-i-i"v-else src="@/static/imagesV2/icon15.png" mode="widthFix"></image>
<view class="HonorWall-c-c-b-i-t">{{ item.name }}</view>
</view>
</view>
</view>
</view>
</view>
</u-popup>
</template>
<script>
export default {
name: 'HonorWall',
props: {
dataList: {
type: Array,
default: () => []
}
},
data() {
return {
show: false
}
},
methods: {
close() {
debugger
this.show = false
},
open() {
this.show = true
}
}
}
</script>
<style lang="scss" scoped>
.HonorWall{
.HonorWall-i{
display: flex;
justify-content: flex-end;
margin-bottom: 20rpx;
}
.HonorWall-c{
position: relative;
height: 760rpx;
width: 650rpx;
.HonorWall-c-bg{
height: 100%;
width: 100%;
}
.HonorWall-c-c{
position: absolute;
top: 0;
left: 0;
padding: 50rpx;
width: 100%;
box-sizing: border-box;
.HonorWall-c-c-t{
font-size: 34rpx;
color: #555D71;
display: flex;
justify-content: center;
.HonorWall-c-c-t-c{
position: relative;
padding: 0 17rpx;
&:before{
content: '';
background-image: url(@/static/imagesV2/icon14.png);
background-size: 100% 100%;
position: absolute;
left: 0;
top: 50%;
height: 36rpx;
width: 36rpx;
transform: translateY(-50%) translateX(-100%);
}
&:after{
content: '';
background-image: url(@/static/imagesV2/icon14s.png);
background-size: 100% 100%;
position: absolute;
right: 0;
top: 50%;
height: 36rpx;
width: 36rpx;
transform: translateY(-50%) translateX(100%);
}
}
}
.HonorWall-c-c-b{
display: grid;
grid-template-columns: repeat(4, auto);
justify-content: space-between;
margin-top: 20rpx;
grid-row-gap: 40rpx;
grid-column-gap: 40rpx;
.HonorWall-c-c-b-i{
text-align: center;
.HonorWall-c-c-b-i-i{
height: 90rpx;
width: 90rpx;
}
.HonorWall-c-c-b-i-t{
font-size: 24rpx;
color: #555D71;
}
}
}
}
}
}
</style>
\ No newline at end of file
... ...
<template>
<view class="sf-padding-top88 PaddingTopB" :style="{paddingTop: PaddingTop, minHeight: minHeight}">
<slot></slot>
</view>
</template>
<script>
export default {
name:"PaddingTopB",
watch: {
otherHeight: {
handler(newData){
this.setOtherHeight(newData)
},
immediate: true
}
},
props: {
otherUnit: {
type: String,
default: 'rpx'
},
otherHeight: {
type: [Number, String],
default: 0
},
minHeight: {
type: String,
default: 'calc(100vh)'
}
},
data() {
return {
PaddingTop: 0
};
},
mounted() {
},
methods:{
setOtherHeight(height, unit = 'rpx') {
// #ifdef MP-WEIXIN
let res = wx.getMenuButtonBoundingClientRect();
// #endif
let paddingTop = res.top
let titleHeight = res.height + 10;
this.PaddingTop = `calc(${paddingTop + titleHeight}px + ${height + this.otherUnit})`
// this.PaddingTop = `calc(${uni.getSystemInfoSync().statusBarHeight}px + ${height}rpx + 88rpx + 5px)`
}
}
}
</script>
<style lang="scss" scoped>
.sf-padding-top88{
// position: fixed;
box-sizing: border-box;
position: relative;
width: 100%;
z-index: 20;
}
.PaddingTopB{
display: flex;
}
</style>
\ No newline at end of file
... ...
<template>
<u-popup :show="show" mode="center" bgColor="transparent">
<view class="PopupA">
<view class="PopupA-1">
<image class="PopupA-1-bg" src="@/static/images/xh_icon10.png"></image>
<view class="PopupA-1-content">
<view class="PopupA-1-content-icon">
<image src="@/static/images/xh_icon11.png" mode=""></image>
</view>
<view class="PopupA-1-content-title">
<image class="PopupA-1-content-title-icon" src="@/static/images/xh_icon12.png" ></image>
<text class="PopupA-1-content-title-text">{{ title }}</text>
<image class="PopupA-1-content-title-icon" src="@/static/images/xh_icon12.png" ></image>
</view>
<view class="PopupA-1-content-details">
“恭喜你获得中志教育荣誉勋章凭截图可到学生服务中心领取奖品一份”
</view>
</view>
</view>
<view class="PopupA-2">
<u-icon name="close-circle" color="#fff" size="32" @click.native="close"></u-icon>
</view>
</view>
</u-popup>
</template>
<script>
export default {
name: 'PopupA',
data() {
return {
show: false,
title: ''
}
},
methods: {
open({title} = e) {
this.title = title
this.show = true
},
close() {
this.show = false
this.$emit('close')
}
}
}
</script>
<style lang="scss" scoped>
.PopupA{
.PopupA-1{
position: relative;
padding: 140rpx 35rpx 100rpx 35rpx;
height: 830rpx;
width: 640rpx;
.PopupA-1-bg{
position: absolute;
height: 830rpx;
width: 640rpx;
top: 0;
left: 0;
}
.PopupA-1-content{
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.PopupA-1-content-icon{
height: 370rpx;
width: 370rpx;
}
.PopupA-1-content-title{
display: flex;
align-items: center;
.PopupA-1-content-title-text{
font-size: 32rpx;
color: #422511;
margin: 0 25rpx;
font-weight: bold;
}
.PopupA-1-content-title-icon{
height: 38rpx;
width: 38rpx;
}
}
.PopupA-1-content-details{
text-align: center;
color: #72482A;
font-size: 26rpx;
margin-top: 26rpx;
padding: 0 20rpx;
}
}
}
.PopupA-2{
display: flex;
justify-content: center;
margin-top: 37rpx;
}
}
</style>
\ No newline at end of file
... ...
<template>
<view>
<view class="stu_list">
<!-- datas_stu -->
<view class="add_li">
<picker mode="selector" :range="datas_stu" range-key="name" @change="stu_change">
<view class="add_li_box">
<view class="">
学员姓名
</view>
<input type="text" placeholder="请选择" v-model="name" disabled="true">
</view>
</picker>
</view>
<view class="add_li">
<picker mode="date" :value="sx_time" :start="startDate" :end="endDate" @change="bindDateChange">
<view class="add_li_box">
<view class="">
访谈时间
</view>
<view class="">
{{sx_time?sx_time:'请选择'}}
</view>
</view>
</picker>
</view>
<view class="add_li">
<view class="add_li_box">
<view class="">
班主任自我介绍
</view>
<view class="sf_v_btn_b" :class="{active:is_teacher==1}" @click="set_tch">
<text class="icon icon-duigou"></text>
</view>
</view>
</view>
<view class="add_li">
<view class="add_li_tit">
了解学生信息(专业、学校、政治面貌、籍贯)
</view>
<textarea class="add_li_content" placeholder="请输入" v-model="content_one"></textarea>
</view>
<view class="add_li">
<view class="add_li_tit">
第几次考编,之前有没有参加培训,有没有短板模块
</view>
<textarea class="add_li_content" placeholder="请输入" v-model="content_two"></textarea>
</view>
<view class="add_li">
<view class="add_li_box">
<view class="">
介绍近期课程安排、纪律要求
</view>
<view class="sf_v_btn_b" :class="{active:is_introduce==1}" @click="set_tch1">
<text class="icon icon-duigou"></text>
</view>
</view>
</view>
<view class="add_li">
<view class="add_li_tit">
有无什么要求,是否适应
</view>
<textarea class="add_li_content" placeholder="请输入" v-model="content_three"></textarea>
</view>
<view class="add_li">
<view class="add_li_box">
<view class="">
入学测评成绩分析
</view>
<view class="sf_v_btn_b" :class="{active:is_result==1}" @click="set_tch2">
<text class="icon icon-duigou"></text>
</view>
</view>
</view>
</view>
<view class="bz_add" >
<view class="" @click="save_fuc">
保存
</view>
<view v-if="options.id" class="del_btn" @click="del_fuc(options)">
删除
</view>
</view>
</view>
</template>
<script>
import Vue from 'vue'
import {
mapState,
mapMutations
} from 'vuex'
var that1
export default {
name:"ft_add",
props: {
options:{
type: Object,
default: function () {
return {}
}
}
},
data() {
return {
id:'',
uid:'',
name:'',
sx_time:'',
is_teacher:2,
is_introduce:2,
is_result:0,
content_one:'',
content_two:'',
content_three:'',
datas_stu:'',
datas:'',
};
},
computed: {
...mapState(['hasLogin', 'forcedLogin', 'userName', 'userinfo', 'nowtime']),
startDate() {
return this.getDate('start');
},
endDate() {
return this.getDate('end');
}
},
mounted() {
that1=this
that1.getdata_stu()
},
methods:{
del_fuc(item){
//teacher/interviewr_del 常规访谈删除接口
//teacher/interview_del 入学关怀删除接口
uni.showModal({
title: '提示',
content: '是否删除该记录',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
var jkurl='/teacher/interview_del'
// if(that.active==1){
// kurl='teacher/interview_del'
// }
var datas={
id:item.id
// address_id:''
}
var header={
'content-type': 'application/json',
}
// that.$service.P_post(jkurl, datas,header).then(res => {
that1.$service.P_post(jkurl, datas).then(res => {
that1.btnkg = 0
console.log(res)
if (res.code == 1){
that1.htmlReset = 0
var datas = res.data
console.log(typeof datas)
if (typeof datas == 'string') {
datas = JSON.parse(datas)
}
console.log(res)
uni.showToast({
icon:'none',
title:'删除成功'
})
// that1.datas.splice(index,1)
setTimeout(()=>{
uni.navigateBack({
delta:1
})
},1000)
} else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '获取数据失败'
})
}
}
}).catch(e => {
that1.htmlReset = 1
that1.btnkg = 0
// that1.$refs.htmlLoading.htmlReset_fuc(1)
console.log(e)
uni.showToast({
icon: 'none',
title: '获取数据失败,请检查您的网络连接'
})
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
stu_change(e){
var index=e.detail.value
this.name = that1.datas_stu[index].name
this.uid = that1.datas_stu[index].id
},
set_tch(){
if(that1.is_teacher==1){
that1.is_teacher=2
}else{
that1.is_teacher=1
}
},
set_tch1(){
if(that1.is_introduce==1){
that1.is_introduce=2
}else{
that1.is_introduce=1
}
},
set_tch2(){
if(that1.is_result==1){
that1.is_result=2
}else{
that1.is_result=1
}
},
getdata_stu() {
var jkurl="/teacher/student"
var datas={
is_interview: 1
// page:that1.page,
}
// if(that1.data_last == true){
// return
// }
if (that1.btnkg == 1) {
return
} else {
that1.btnkg = 1
}
var page_now=1
that1.$service.P_post(jkurl, datas).then(res => {
that1.btnkg = 0
console.log(res)
if (res.code == 1) {
var datas = res.data
console.log(typeof datas)
if (typeof datas == 'string') {
datas = JSON.parse(datas)
}
if (page_now == 1) {
that1.datas_stu = datas
if(that1.options&&that1.options.id){
that1.getdata()
}
} else {
// if (datas.data.length == 0) {
// that.data_last = true
// return
// }
// that.data_last = false
// that.datas = that.datas.concat(datas.data)
}
// that1.page++
} else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '操作失败'
})
}
}
}).catch(e => {
that1.btnkg = 0
console.log(e)
uni.showToast({
icon: 'none',
title: '操作失败'
})
})
},
getdata() {
var jkurl="/teacher/interview_show"
var datas={
id:that1.options.id,
}
// if(that1.data_last == true){
// return
// }
if (that1.btnkg == 1) {
return
} else {
that1.btnkg = 1
}
var page_now=that1.page
that1.$service.P_post(jkurl, datas).then(res => {
that1.btnkg = 0
console.log(res)
if (res.code == 1) {
var datas = res.data
console.log(typeof datas)
if (typeof datas == 'string') {
datas = JSON.parse(datas)
}
that1.datas=datas
that1.id=datas.id
that1.uid=datas.uid
that1.name=datas.name
that1.is_teacher=datas.is_teacher
that1.content_one=datas.content_one
that1.content_two=datas.content_two
that1.is_introduce=datas.is_introduce
that1.content_three=datas.content_three
that1.is_result=datas.is_result
that1.sx_time=datas.add_time
} else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '操作失败'
})
}
}
}).catch(e => {
that1.btnkg = 0
console.log(e)
uni.showToast({
icon: 'none',
title: '操作失败'
})
})
},
bindDateChange(e) {
var sx_time = e.detail.value
sx_time=sx_time.split('-')
sx_time=sx_time.join('/')
that1.sx_time=sx_time
},
save_fuc() {
var jkurl="/teacher/interview_add"
var datas={
uid:that1.uid,
name:that1.name,
is_teacher:that1.is_teacher,
content_one:that1.content_one,
content_two:that1.content_two,
is_introduce:that1.is_introduce,
content_three:that1.content_three,
is_result:that1.is_result,
add_time:that1.sx_time
}
if(that1.id){
jkurl="/teacher/interview_edit"
datas={
id:that1.id,
...datas
}
}
that1.$service.P_post(jkurl, datas).then(res => {
that1.btnkg = 0
console.log(res)
if (res.code == 1) {
var datas = res.data
console.log(typeof datas)
if (typeof datas == 'string') {
datas = JSON.parse(datas)
}
uni.showToast({
icon: 'none',
title: '保存成功'
})
setTimeout(function() {
uni.navigateBack({
delta: 1
})
}, 1000)
} else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '操作失败'
})
}
}
}).catch(e => {
that1.btnkg = 0
console.log(e)
uni.showToast({
icon: 'none',
title: '操作失败'
})
})
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 60;
} else if (type === 'end') {
year = year;
}
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
}
}
</script>
<style lang="less" scoped>
.stu_list {
width: 100%;
min-height: 100rpx;
background: #FFFFFF;
border-radius: 10rpx;
.add_li{
width: 100%;
min-height: 90rpx;
padding:28rpx 30rpx;
&+.add_li{
border-top: 1px solid #eee;
}
.add_li_box{
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 30rpx;
color: #545d71;
input{
text-align: right;
min-width: 0;
font-size: 30rpx;
}
.sf_v_btn_b{
display: flex;
align-items: center;
justify-content: center;
font-size: 18rpx;
color: #fff;
width: 32rpx;
height: 32rpx;
border: 1px solid #DEDEDE;
border-radius: 8rpx;
&.active{
background: #2D81FF;
border: 1px solid #2D81FF;
}
text{
font-size: 18rpx;
line-height: 20rpx;
}
}
}
.add_li_tit{
font-size: 30rpx;
color: #545D71;
line-height: 43rpx;
margin-bottom: 12rpx;
}
.add_li_content{
font-size: 30rpx;
color: #A6A9B1;
line-height: 43rpx;
width: 100%;
height: 120rpx;
letter-spacing:0;
}
}
}
.bz_add{
width: 100%;
// position: fixed;
// bottom: 0;
// background: #f8f8f8;
// z-index: 800;
// left: 0;
padding: 30rpx 0;
view{
font-size: 32rpx;
color: #FFFFFF;
width: 100%;
height: 90rpx;
background: #2D81FF;
border-radius: 10rpx;
display: flex;
align-items: center;
justify-content: center;
}
.del_btn{
margin-top: 20rpx;
}
}
</style>
\ No newline at end of file
... ...
<template>
<view>
<view class="stu_list">
<view class="add_li">
<picker v-if="datas_stu.length>0" mode="selector" :range="datas_stu" range-key="name" @change="stu_change">
<view class="add_li_box">
<view class="">
学员姓名
</view>
<input type="text" placeholder="请选择" v-model="name" disabled="true">
</view>
</picker>
</view>
<view class="add_li">
<picker mode="date" :value="sx_time" :start="startDate" :end="endDate" @change="bindDateChange">
<view class="add_li_box">
<view class="">
访谈时间
</view>
<view class="">
{{sx_time?sx_time:'请选择'}}
</view>
</view>
</picker>
</view>
<view class="add_li" v-for="(item,index) in diy_data">
<view class="add_li_tit">
{{item.title}}
</view>
<view class="add_li_content">
{{item.content}}
</view>
</view>
<view class="add_li">
<view class="add_li_box">
<view class="">
自定义标题与内容
</view>
<view class="add_diy" @click="tk_show=true">
添加
</view>
</view>
</view>
</view>
<u-popup :show="tk_show" @close="close" @open="open">
<view class="tk_box_s">
<view class="pop_tit">
<view class="" @click="close">
取消
</view>
<view class="pop_tit_t" @click="save_diy">
确定
</view>
</view>
<input class="diy_tit" type="text" placeholder="请输入标题" v-model="diy_tit">
<textarea class="diy_content" placeholder="请输入内容" v-model="diy_content"></textarea>
</view>
</u-popup>
<view class="bz_add" >
<view class="" @click="save_fuc">
保存
</view>
<view v-if="options.id" class="del_btn" @click="del_fuc(options)">
删除
</view>
</view>
</view>
</template>
<script>
import Vue from 'vue'
import {
mapState,
mapMutations
} from 'vuex'
var that1
export default {
name:"ft_add1",
props: {
options:{
type: Object,
default: function () {
return {}
}
}
},
data() {
return {
id:'',
uid:'',
name:'',
sx_time:'',
tch_js:0,
js_other:0,
result_ask:0,
content:'',
content1:'',
content2:'',
tk_show:false,
diy_tit:'',
diy_content:'',
diy_data:[],
datas_stu:[]
};
},
computed: {
...mapState(['hasLogin', 'forcedLogin', 'userName', 'userinfo', 'nowtime']),
startDate() {
return this.getDate('start');
},
endDate() {
return this.getDate('end');
}
},
mounted() {
that1=this
that1.getdata_stu()
},
methods:{
del_fuc(item){
//teacher/interviewr_del 常规访谈删除接口
//teacher/interview_del 入学关怀删除接口
uni.showModal({
title: '提示',
content: '是否删除该记录',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
var jkurl='teacher/interviewr_del'
var datas={
id:item.id
// address_id:''
}
var header={
'content-type': 'application/json',
}
// that.$service.P_post(jkurl, datas,header).then(res => {
that1.$service.P_post(jkurl, datas).then(res => {
that1.btnkg = 0
console.log(res)
if (res.code == 1){
that1.htmlReset = 0
var datas = res.data
console.log(typeof datas)
if (typeof datas == 'string') {
datas = JSON.parse(datas)
}
console.log(res)
uni.showToast({
icon:'none',
title:'删除成功'
})
// that1.datas.splice(index,1)
setTimeout(()=>{
uni.navigateBack({
delta:1
})
},1000)
} else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '获取数据失败'
})
}
}
}).catch(e => {
that1.htmlReset = 1
that1.btnkg = 0
// that1.$refs.htmlLoading.htmlReset_fuc(1)
console.log(e)
uni.showToast({
icon: 'none',
title: '获取数据失败,请检查您的网络连接'
})
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
stu_change(e){
var index=e.detail.value
this.name = that1.datas_stu[index].name
this.uid = that1.datas_stu[index].id
},
getdata_stu() {
var that1=this
console.log(this.options)
var jkurl="/teacher/student"
var datas={
// page:that1.page,
}
// if(that1.data_last == true){
// return
// }
if (that1.btnkg == 1) {
return
} else {
that1.btnkg = 1
}
var page_now=1
that1.$service.P_post(jkurl, datas).then(res => {
that1.btnkg = 0
console.log(res)
if (res.code == 1) {
var datas = res.data
console.log(typeof datas)
if (typeof datas == 'string') {
datas = JSON.parse(datas)
}
if (page_now == 1) {
that1.datas_stu = datas
console.log(that1.datas_stu)
if(that1.options.id){
that1.getdata()
}
} else {
// if (datas.data.length == 0) {
// that.data_last = true
// return
// }
// that.data_last = false
// that.datas = that.datas.concat(datas.data)
}
// that1.page++
} else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '操作失败'
})
}
}
}).catch(e => {
that1.btnkg = 0
console.log(e)
uni.showToast({
icon: 'none',
title: '操作失败'
})
})
},
getdata() {
var jkurl="/teacher/interviewr_show"
var datas={
id:that1.options.id
}
// if(that1.data_last == true){
// return
// }
if (that1.btnkg == 1) {
return
} else {
that1.btnkg = 1
}
var page_now=that1.page
that1.$service.P_post(jkurl, datas).then(res => {
that1.btnkg = 0
console.log(res)
if (res.code == 1) {
var datas = res.data
console.log(typeof datas)
if (typeof datas == 'string') {
datas = JSON.parse(datas)
}
that1.datas=datas
that1.id=datas.id
that1.uid=datas.uid
that1.name=datas.name||''
that1.sx_time=datas.add_time
that1.diy_data=datas.content||[]
} else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '操作失败'
})
}
}
}).catch(e => {
that1.btnkg = 0
console.log(e)
uni.showToast({
icon: 'none',
title: '操作失败'
})
})
},
open() {
// console.log('open');
},
close() {
this.tk_show = false
// console.log('close');
},
save_diy(){
if(!that1.diy_tit){
uni.showToast({
icon:'none',
title:'请输入标题'
})
return
}
if(!that1.diy_content){
uni.showToast({
icon:'none',
title:'请输入内容'
})
return
}
var datas={
title:that1.diy_tit,
content:that1.diy_content
}
that1.diy_data.push(datas)
that1.diy_tit=''
that1.diy_content=''
this.tk_show = false
},
bindDateChange(e) {
var sx_time = e.detail.value
sx_time=sx_time.split('-')
sx_time=sx_time.join('/')
that1.sx_time=sx_time
},
save_fuc() {
var jkurl="/teacher/interviewr_add"
var datas={
uid:that1.uid,
name:that1.name,
content:JSON.stringify(that1.diy_data),
add_time:that1.sx_time
}
if(that1.id){
jkurl="/teacher/interviewr_edit"
datas={
id:that1.id,
...datas
}
}
that1.$service.P_post(jkurl, datas).then(res => {
that1.btnkg = 0
console.log(res)
if (res.code == 1) {
var datas = res.data
console.log(typeof datas)
if (typeof datas == 'string') {
datas = JSON.parse(datas)
}
uni.showToast({
icon: 'none',
title: '保存成功'
})
setTimeout(function() {
uni.navigateBack({
delta: 1
})
}, 1000)
} else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '操作失败'
})
}
}
}).catch(e => {
that1.btnkg = 0
console.log(e)
uni.showToast({
icon: 'none',
title: '操作失败'
})
})
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 60;
} else if (type === 'end') {
year = year;
}
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
}
}
</script>
<style lang="less" scoped>
.stu_list {
width: 100%;
min-height: 100rpx;
background: #FFFFFF;
border-radius: 10rpx;
.add_li{
width: 100%;
min-height: 90rpx;
padding:28rpx 30rpx;
&+.add_li{
border-top: 1px solid #eee;
}
.add_li_box{
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 30rpx;
color: #545d71;
input{
text-align: right;
min-width: 0;
font-size: 30rpx;
}
.sf_v_btn_b{
display: flex;
align-items: center;
justify-content: center;
font-size: 18rpx;
color: #fff;
width: 32rpx;
height: 32rpx;
border: 1px solid #DEDEDE;
border-radius: 8rpx;
&.active{
background: #2D81FF;
border: 1px solid #2D81FF;
}
text{
font-size: 18rpx;
line-height: 20rpx;
}
}
.add_diy{
font-size: 30rpx;
color: #2D81FF;
}
}
.add_li_tit{
font-size: 30rpx;
color: #545D71;
line-height: 43rpx;
margin-bottom: 12rpx;
}
.add_li_content{
font-size: 30rpx;
color: #A6A9B1;
line-height: 43rpx;
width: 100%;
// height: 120rpx;
letter-spacing:0;
}
}
}
.bz_add{
width: 100%;
// position: fixed;
// bottom: 0;
// background: #f8f8f8;
// z-index: 800;
// left: 0;
padding: 30rpx 0;
view{
font-size: 32rpx;
color: #FFFFFF;
width: 100%;
height: 90rpx;
background: #2D81FF;
border-radius: 10rpx;
display: flex;
align-items: center;
justify-content: center;
}
.del_btn{
margin-top: 20rpx;
}
}
.pop_tit{
width: 100%;
height: 100rpx;
font-size: 30rpx;
color: #A9B1C0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 30rpx;
.pop_tit_t{
color: #2D81FF;
}
}
.tk_box_s{
// height: 600rpx;
background: #ffffff;
}
.diy_tit{
width: 100%;
height: 100rpx;
padding: 0 30rpx;
font-size: 30rpx;
color: #333;
border-bottom: 1px solid #EEEEEE;
}
.diy_content{
width: 100%;
height: 790rpx;
padding: 30rpx;
font-size: 30rpx;
color: #333;
box-sizing: border-box;
}
</style>
\ No newline at end of file
... ...
<template>
<view class="mll">
<block v-if="!isError">
<image v-if="isShow" :src="src" :mode="mode" @tap="clickImg"
:style="{
opacity: Number(opacity),
borderRadius: borderRadius + 'rpx',
// 因为time值需要改变,所以不直接用duration值(不能改变父组件prop传过来的值)
transition: `opacity ${time / 1000}s ease-in-out`
}"></image>
<image v-else :src="loadingImg" mode="aspectFill" @error="loadError" @tap="clickImg"></image>
</block>
<image v-else :src="errorImg" mode="aspectFill" :title="errorImg" @tap="clickImg"></image>
<image class="test_img" :src="src" mode="aspectFill" @load="imgLoaded" @error="loadError"></image>
</view>
</template>
<script>
export default {
name:"my_lazy_load",
props: {
index: {
type: [Number, String]
},
src:{
type: String,
default: ''
},
mode:{
type: String,
default: ''
},
// 占位图片路径
loadingImg: {
type: String,
default: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAMAAAC3Ycb+AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OUM0QjNBQjkyQUQ2MTFFQTlCNUQ4RTIzNDE5RUIxNjciIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OUM0QjNBQkEyQUQ2MTFFQTlCNUQ4RTIzNDE5RUIxNjciPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5QzRCM0FCNzJBRDYxMUVBOUI1RDhFMjM0MTlFQjE2NyIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo5QzRCM0FCODJBRDYxMUVBOUI1RDhFMjM0MTlFQjE2NyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PtRHfPcAAAAzUExURZWVldfX18PDw62trZubm9zc3Li4uKGhoebm5tLS0uHh4c3Nzaenp729vcjIyLKysuvr6141L40AAAcXSURBVHja7NzZlqpGAEBR5lG0//9rIw7IJKJi4or7PGTdtN10wr5SVAEGf/qqArsAiIAAERAgAgJEQIAIiIAAERAgAgJEQIAIiIAAERAgAgJEQIAIiIAAERAgAgJEQIAIiIAAERAgAgJEQIAIiIAAERAgAgJEQIAIiIAAERAgAgJEQIAIiIAAERAgAgJEQIAIiIAAERAgAgJEQIAIiIAAERAgAgJEQIAICBABERAgAgJEQIAICBABERAgAgJEQIAICBABERAgAgJEQIAICBABERAgAgJEQIAICBABERAgAgJEQIAICBABERAgAgJEQIAICBABERAgAgJEQIAICBABERAgAgJEQIAICBABERAg+nmQFMi5Jis+sIniED23jSzIgLTtg2D//iYme/8QBM/9lQ+CAEhbNLM3N9hEHAThX7GPCiBfAxK1b51kD+R7QMLjXg7iCsgWIPUh7pfVozG791oeBPngm48G583uW5GkBvI+SBaM2xXDn1oqum423bX/mgF5FySc2cv93Voug9TdZotsggnkBZB2NzbhrSY5HnoG07jei8dvzsJB/c3W60SALILE46+WCztsbhPR7R2VJq0ukEcT49nyy8QhaKcRa3fYHZD4+ufqOJAcgDz8/59vtw1I3QP5K6JsOG0vm3hce4I8LQp/BaRZGJC3AAn7IKOKXbC+7EdA5vdmmVwOLksgRThqOqiH4XEGsht+peoPUE8U/jJIO5OLH4GEwUslV5G0PTBG5Uiw/Y2jyigO3l9HAHKv9PYb82LloH74dZBoBUgar+l48NsNvtD0fkez9iwrAvIYZDRCl+Xs149Hm/KZmQ+QjUCiO1ei4ru7EsgnQYrkznlQb7thCuRfAzlOAPN72427P4VA/i2Q/DKT/Ls/VR8fvIBsDZIuz7TPF6TCbnk4GJkB2RokejTjuE7/unlgCuSTIO0Cy+Plp6vDfnQlBchy8QtjSHVd3EgmK1bHLm+H6+nXYbz2DuQRSPnqoL7vvq0u70on4zvxgCyWD3b9UyDVdW24PaWaiGTnFZJwPIQAebDpIKheBIm7n124ZthMJipAlkqHO+IZkP1tbfzOJark/A7MgKyvvl60fRqkvXfhuow+t9+q00+0/yyBrK8ZngOtBzldhw2X9tvpNGty0gvkmbPeJ0Cy/r09s/stbmfo0yMWkEdjevgKyOn2t2pxv7UXoibTdCDLje9/Ww1ymqzn87dbp92242ZmMRjI8hASvwKSLq4udqN6ksw8nxXN3tszD9L8Gkg+2mFrQYql5az4tvFj5xOx4VwnSdeBtGdyPwUytxK77pBVlNHdO7OK3rh/eTPUvdutT3fO52tuHMqD4N7llv8pyOQQ//w19YVDfX27+Sfuby9/6nau4pdA8vEdOZuChEH/quHt0Jg+IRJ/5+PrHwKZXfjbDiS73Zo7mu5UkzX7uTsXe0e/7nC3ePf1O69+BUg2XDfZCqSqOu7rGVf8cHBe8zhC2b61dtUHXv0OkGo6ZL4JkpbRYXdUaFevivx2M/1GIOctNh949TtAoumQ+TpIHMX54CJu+8BDd8FkE5BqcZh/59XvAClmTvKfB0nDqIlHo3T70SftyW1eX9dXtgQJqs1f/Q6QaOa/7wmQKtxH8eiGoCRuovODIO3VxOMmruZbHrLyD7z6DSDtGyT7ew1kf9hNn07c986JTovzzem0Id9wUG+Vk/IDr34DSNR7huZJkMFT6vEhqrPx/j5cnlZML8N6/PAzh9Y99Flm5Yde/c9BquDOkvkKkMP58dA4qi9vivE8JOvGz/j8FokfPpr288+pH2ZPOZrLmeGD+7KOh6dqYWJ48ki7yUg0tz0go/fv/LLddfV3sgOLJyaGPY/zrSlh1a36Arkzoue9CyG35ze6E6/dzO2Ga0EGHqdRJIkfn9/8OEjTW8Vq91ZWh39FeehWA7Nu9ft8CpUEk1WWOyDF0OPyEU2Pnzf/bZC0P6IPzmAvu7KauQBVrgKpJ0tG2arHzX8e5Pb3PezNs/PrX+3JMyCLn9XXf37tPFHvt09WfCDDjx+yyn1/p1V11j7GnB/q3leLuVva79S/tzed+db08YpF4uOZtmz/9oXWMq6BCAgQAQEiIEAERECACAgQAQEiIEAERECACAgQAQEiIEAERECACAgQAQEiIEAERECACAgQAQEiIEAERECACAgQAQEiIEAERECACAgQAQEiIEAERECACAgQAQEiIEAERECACAgQAQEiIEAERECACAgQAQEiIEAEBIiACAgQAQEiIEAEBIiACAgQAQEiIEAEBIiACAgQAQEiIEAEBIiACAgQAQEiIEAEBIiACAgQAQEiIEAEBIiACAgQAQEiIEAEBIiACAgQAQEiIEAEBIiACAgQAQEiIEAEBIiACAgQAQEiIEAEBIiAALELvqt/BBgACqVeUBXxcCkAAAAASUVORK5CYII='
},
// 加载失败的错误占位图
errorImg: {
type: String,
default: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAMAAAC3Ycb+AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6ODdDMjhENDYyQUQ2MTFFQTlDQ0VBODgxQjFFOEEyMEMiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6ODdDMjhENDcyQUQ2MTFFQTlDQ0VBODgxQjFFOEEyMEMiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo4N0MyOEQ0NDJBRDYxMUVBOUNDRUE4ODFCMUU4QTIwQyIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4N0MyOEQ0NTJBRDYxMUVBOUNDRUE4ODFCMUU4QTIwQyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PhLwhikAAAAzUExURZWVldfX162trcPDw5ubm7i4uNzc3Obm5s3NzaGhoeHh4cjIyKenp9LS0r29vbKysuvr67sDMEkAAAlpSURBVHja7NzpYqMgAIVRUVHc8/5PO66R1WAbOzX97q+ZtDEpR0AWTR7kVyWhCAAhgABCAAGEAAIIAQQQAggBBBACCCAEEEAIIIAQQAgggBBAACGAAEIAAYQAQgABhAACCAEEEAIIIAQQAgggBBBACCCAEEAAIYAQQAAhgABCAAGEAAIIAYQAAggBBBACCCAEEEAIIAQQQAgggBBAACGAAEIAIYAAQgABhAACCAEEEAIIAQQQAgggBBBACCCAEEAAIYAQQAAhgABCAAGEAAIIAYQAAggBBBACCCAEEEAIIAQQQAgggBBAACGAAEIAIYAAQgABhAACCAEEEAIIAQQQAgggBBBACCCAEEAIIIAQQAAhgABCAAGEAEIAAYQAAggBBBACCCAEEAIIIAQQQAgggBBAACGAEEAAIYAAsqeX5QWHKIcs/Ptl03lfL4zDFPWfBGmSpPn+IZzSH5KkCL5B+n+oklwz6Iz//R2QzFOabzhEmiRirAmZt/bl0w/dpMbLqeeo4wEdpC7zR5WAPKziHKtO7ql+ReKvIa9BxgNaL5ZtEkpeAGIVp5jKJa09xVo9vgSSzQcszdYvmOqjQNSQ6pHK6rO1n1Xj32788miwHLaZz1Tl9i/yayDlYJ/60/+lp8GSY7OY1B8E4p55bWmfquFk22GLuUUxi78cX+m+BjL2GLkhMrV+/muS6Sfic0CEp5T1Yu2OQdTzsKV0MJV73KVjroyTffxfuv5Tf3fd6iLT9wz8YdVHgUzF2Is9/Xhi5sYJqP1w/GUpjOiHVbaI0w2L+pg3GZzvtokcgHxWDXHaiy78l3sPke01qphamT5c+dqyeAGSumdL/mkggauTam0e3L/mPEiqtzKDbl0Z1Wn8xOa4ySo8X/7TQIJnY/seEKWf12UmC72CKP9xYjr19RPT7NNA+oMO+R0gwmlotAry+C6I0f59ch8yXVQOr0BKYcXt1IUYRyCt+Ur9HGsrQKI79WY9sY9ARPKlzFOFdb41ioD8b5Bp+mqeeRKAxINkESBFGpOpKhgv9OuYpH8A8l4Qa3qp60Kl2/k+rG2sWafuuyCBafb2j4JkgZUob3nWcmicpkxEgmTLLGejTxnWSWCi8lPmsk6DlIHFJv24ojiYyYoGacwL8zXTLEAVaDI/Ybb3NIgKDSv2oXpmHkvNs+PTpMASEdlk7fOZeRk37fwJ6yGnQarQsGIfqqcvx43rTOXY6jf7uKXdRzdLDRPbjIrx1cIj3Kr4KyBFezzgUGuR5893qkOQ19fR2uVBaU+r16LphJNOiatK7PeBZK/Kb+tUn71rcQjSvARpghfH/yG/D2RetTuI3N5QrMWdP46brP7FmKZ//CGQ9At9SL01DLkzY/Vs8Z97fQZ7gelw7jHqCz+/Wile5J4g3Vc79eb5a6oLSue+Ve83gaSv2jp5PxCzjzwFUm9zw9MllSMil1kS4d2E9SaQ1xNo9wMxx0+nQNLnew/WDHvveMAHYm08mofl3TFI/8pD3Q6kMAv6DIi2jTCwRJUvNdDYrrJum9oHhusCbWALonwxBRk1vXMnEGWuT5wAmfYuVGUYpJ7fUZujCN92hvzwWlrFgxSfANKb10DxIMbShnfrynyZZV30imA7P43ArXXHbvBVkTCIuGy25AdBrHmNeBCpL214QdLp9LZarG3IMWrmW0ehtuO7F2PS09UcgqS3B7FKPhpknrStD0HGF/vQRne37LwLG8EbHT4WxN7/Fg0yD9Yr/3br4nnstA+0Il6QxzdBmg8A6a2/IRbkcK9h/uzV8zywF/oSkOyageCPglRWgcWClHnEzs9q/t/SENVXgFijlsq3VtXdCsRp4qObrLLLgjuzSq3fX89ZZW6AfxNIzF6X9FYgThN/fk093KkvHX/hbWd+DqS/FUhlf+G3gohEXzVs3g9iDluWoaW8fL73QhB34u+tIHIf19nLuF4Q98a09Eynnl56q+ePgEhnX+dbQOp6H5XnJ0ACd8dFgkwf12nTOTcEqd2pom+CFF02TIPw6dKmrLS5qOtBpo8b5quUtrwrSGbuqPkeSJqllTFHO02NPxdMrm+y5LKdWyWXjw4vA5nGEtnjuyCFyHqNYvEolzmASm3zK1Eg5zr13lhqV1tlksnVw8Pkwgri7O07AVKLJkutRYw87bPlRpBpNXE8xGb+fhBlvEGrGPLqViu5sILIx9dAmqF1705sxF4M8+R8P5dOdQwi12fMnATpjJ2JSt/POIvU9wPJEs/jduJAjLvU0yFT0i64Yb1bsVi79dA4pEy3TzoHMq2O7Re4vXm5O9+l290NpE4CU+YRIMNye2iaqbVS2AUnn2fsekthYKReVNutVedA5juttyIXrT38mOds+ps9DWhwL7GWc61/DVKPzVN9UHDarf1icU98IOU8tm6L031Iq63t1tKzj3fe/FCpO4F0/i0Z2+yvA1KeGBjqj1qYx8/zoxpKZ1Yl367I1k+sfcft/QPy9csXy/32qX1qLZsrryG5BGQaRj0vc/b7N54XXq293TCLB5HO42Fy517obW19b+qjl3CHp0fdLJcWvmdy1etESi/uAdJrs1hTaUklHuW8qSDdC3UfXVR5cnD3rAFSSqtFb7z7eapErx7rC739jCXfbK3aWiipjXo8UbmxXPa7QQq9R289j2Gr88N7Ag5AlHPRKc37pNZv0CZtX1tVMG6rm8qW1/KlCgQvcMss933ybwXZz3dReW5yce4ByZtHFIhwT9kmjxg8BzbKDUe1PB9edBJqSN7/KM1LmqyuMZ5BpeTUw1aD/uDI0relPfSHa/Wn8Pxq1BNfxy/h3IdwOJqIKumb9CHvTqMefyY82RoQAgggBBBACCCAEEAAIYAQQAAhgABCAAGEAAIIAYQAAggBBBACCCAEEEAIIAQQQAgggBBAACGAAEIAIYAAQgABhAACCAEEEAIIAQQQAgggBBBACCCAEEAIIIAQQAAhgABCAAGEAEIAAYQAAggBBBACCCAEEAIIIAQQQAgggBBAACGAEEAAIYAAQgABhAACCAEEEAIIAQQQAgggBBBACCCAEEAIIIAQQAAhgABCAAGEAEIAAYQAAggBBBACCCAEEAIIIAQQQAgggBBAACGAEEAAIYAAQgABhAACCAGEAAIIAQQQAgggBBBACCAEEEAIIIAQQAAhgABCACGAAEIAAYQAAggBBBACCAEEEAIIIAQQQAggfyL/BBgA8PgLdH0TBtkAAAAASUVORK5CYII='
},
// 圆角值
borderRadius: {
type: [Number, String],
default: 0
},
// 淡入淡出动画的过渡时间
duration: {
type: [Number, String],
default: 500
},
// 渡效果的速度曲线,各个之间差别不大,因为这是淡入淡出,且时间很短,不是那些变形或者移动的情况,会明显
// linear|ease|ease-in|ease-out|ease-in-out|cubic-bezier(n,n,n,n);
effect: {
type: String,
default: 'ease-in-out'
},
// 是否使用过渡效果
isEffect: {
type: Boolean,
default: true
},
},
data() {
return {
isShow: false,
opacity: 1,
time: 100,
loadStatus: '', // 默认是懒加载中的状态
isError: false, // 图片加载失败
// elIndex: this.$u.guid()
};
},
watch: {
isShow(nVal) {
// 如果是不开启过渡效果,直接返回
if (!this.isEffect) return;
this.time = 0;
// 原来opacity为1(不透明,是为了显示占位图),改成0(透明,意味着该元素显示的是背景颜色,默认的白色),再改成1,是为了获得过渡效果
this.opacity = 0;
// 延时30ms,否则在浏览器H5,过渡效果无效
setTimeout(() => {
this.time = this.duration;
this.opacity = 1;
}, 30)
},
},
methods:{
// 点击图片触发的事件,loadlazy-还是懒加载中状态,loading-图片正在加载,loaded-图片加加载完成
clickImg() {
let whichImg = '';
// 如果isShow为false,意味着图片还没开始加载,点击的只能是最开始的占位图
if (this.isShow == false) whichImg = 'lazyImg';
// 如果isError为true,意味着图片加载失败,这是只剩下错误的占位图,所以点击的只能是错误占位图
// 当然,也可以给错误的占位图元素绑定点击事件,看你喜欢~
else if (this.isError == true) whichImg = 'errorImg';
// 总共三张图片,除了两个占位图,剩下的只能是正常的那张图片了
else whichImg = 'realImg';
// 只通知当前图片的index
this.$emit('click', this.index);
},
// 图片加载完成事件,可能是加载占位图时触发,也可能是加载真正的图片完成时触发,通过isShow区分
imgLoaded() {
// 占位图加载完成
this.isShow=true
return
if (this.loadStatus == '') {
this.loadStatus = 'lazyed';
}
// 真正的图片加载完成
else if (this.loadStatus == 'lazyed') {
this.loadStatus = 'loaded';
// this.$emit('load', this.index);
}
},
// 图片加载失败
loadError() {
this.isError = true;
},
}
}
</script>
<style>
.mll{
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
}
image{
width: 100%;
height: 100%;
}
.test_img{
position: absolute;
top: -10rpx;
left: -10rpx;
width: 10rpx;
height: 10rpx;
opacity: 0;
}
</style>
\ No newline at end of file
... ...
<template>
<view class="praise_Item">
<!-- 学生端显示 -->
<view class="praise_Item-1" v-if="type === LIKETYPE.STUDENTEND">
<view class="praise_Item-1-l" v-if="info.is_my">
<view class="praise_Item-1-l-1" v-if="info.status === OPERATIONSTATUS.ADOPT">已通过</view>
<view class="praise_Item-1-l-1s" v-else-if="info.status === OPERATIONSTATUS.PENDINGREVIEW">待审核</view>
<view class="praise_Item-1-l-1s" v-else>未通过</view>
</view>
<view class="praise_Item-1-l-2">{{ info.create_time }}</view>
</view>
<!-- 老师端/管理员端显示 -->
<view class="praise_Item-t" v-if="type === LIKETYPE.TEACHERSEND || type === LIKETYPE.ADMINEND">
<view class="praise_Item-t-l">
<u--image
shape="circle"
height="72rpx"
width="72rpx"
:src="info.uimg"></u--image>
</view>
<view class="praise_Item-t-r">
<view class="praise_Item-t-r-1">{{ info.uname }}</view>
<view class="praise_Item-t-r-2">{{ info.create_time }}</view>
</view>
</view>
<view class="praise_Item-2">
{{ info.content }}
</view>
<view class="praise_Item-3">
<u--image
v-for="(item, index) in info.imgs"
:key="index"
radius="15rpx"
height="145rpx"
width="145rpx"
@click.native="seeImg(index)"
:src="item"></u--image>
</view>
<view class="praise_Item-4" v-if="type === LIKETYPE.ADMINEND && info.showOperation">
<view class="praise_Item-4-1" @click="operation(OPERATIONSTATUS.REFUSE)">不通过</view>
<view class="praise_Item-4-2" @click="operation(OPERATIONSTATUS.ADOPT)">通过</view>
</view>
</view>
</template>
<script>
import { LIKETYPE, OPERATIONSTATUS } from "@/emit/index.js"
export default {
name:"praise_Item",
props: {
type: {
type: [String, Number],
default: LIKETYPE.STUDENTEND
},
info: {
type: Object,
default: () => {
return {}
}
}
},
data() {
return {
OPERATIONSTATUS,
LIKETYPE
};
},
methods: {
operation(type) {
var datas = {
id: this.info.id,
status: type
}
var jkurl = '/admin/praise_check'
this.$service.P_post(jkurl, datas).then(res => {
this.$emit('success', this.info.id)
})
},
seeImg(index) {
uni.previewImage({
current: index, // 当前显示图片的链接,不填则默认为 urls 的第一张图片
urls: this.info.imgs // 需要预览的图片链接列表
})
}
}
}
</script>
<style lang="scss">
.praise_Item{
background: #fff;
border-radius: 15rpx;
padding: 30rpx;
box-shadow: 7rpx 0rpx 24rpx 0rpx rgba(153,153,153,0.22);
margin-bottom: 20rpx;
.praise_Item-1{
display: flex;
align-items: center;
.praise_Item-1-l{
.praise_Item-1-l-1{
line-height: 36rpx;
padding: 0 7rpx;
background-color: #18BD7A;
font-size: 22rpx;
color: #FFFFFF;
border-radius: 5rpx;
}
.praise_Item-1-l-1s{
line-height: 36rpx;
padding: 0 7rpx;
background-color: #2D9FFF;
font-size: 22rpx;
color: #FFFFFF;
border-radius: 5rpx;
}
}
.praise_Item-1-l-2{
color: #A1A0AB;
font-size: 24rpx;
margin-left: 20rpx;
}
}
.praise_Item-t{
display: flex;
align-items: center;
.praise_Item-t-l{
flex-shrink: 0;
}
.praise_Item-t-r{
margin-left: 25rpx;
.praise_Item-t-r-1{
color: #3D4054;
font-size: 28rpx;
}
.praise_Item-t-r-2{
color: #A1A0AB;
font-size: 24rpx;
}
}
}
.praise_Item-2{
font-size: 26rpx;
line-height: 39rpx;
color: #3D4054;
margin-top: 28rpx;
}
.praise_Item-3{
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-row-gap: 20rpx;
grid-column-gap: 20rpx;
margin-top: 30rpx;
}
.praise_Item-4{
display: flex;
justify-content: flex-end;
padding-top: 20rpx;
border-top: #EEEEEE solid 1rpx;
margin-top: 20rpx;
.praise_Item-4-1{
width: 172rpx;
border: 1rpx solid #2D81FF;
color: #2D81FF;
background: rgba(45,159,255,0.1);
border-radius: 200rpx;
font-size: 28rpx;
line-height: 63rpx;
text-align: center;
}
.praise_Item-4-2{
width: 172rpx;
border: 1rpx solid #2D81FF;
color: #FFFFFF;
background: #2D81FF;
border-radius: 200rpx;
font-size: 28rpx;
line-height: 63rpx;
text-align: center;
margin-left: 29rpx;
}
}
}
</style>
\ No newline at end of file
... ...
<template>
<view>
<view class="public_selector" @click="show = true">
<input type="text" :value="value[keyName]" class="public_selector-input" disabled :placeholder="placeholder" placeholder-class="placeholderClass" />
<u-icon name="arrow-down-fill" size="12" ></u-icon>
</view>
<u-picker :keyName="keyName" :show="show" :columns="columns" @confirm="confirm" @cancel="show = false"></u-picker>
</view>
</template>
<script>
export default {
name:"public_selector",
props: {
placeholder: {
type: String,
default: ''
},
keyName: {
type: String,
default: ''
},
value: {
type: Object,
default: () => {
return {}
}
},
columns: {
type: [Array],
default: () => []
}
},
data() {
return {
show: false
};
},
methods: {
confirm(e) {
console.log(e)
this.show = false
this.$emit('change', e)
}
}
}
</script>
<style lang="scss" scoped>
.public_selector{
background: #FFFFFF;
border-radius: 10rpx;
padding: 0 30rpx;
height: 76rpx;
box-shadow: 7rpx 0rpx 24rpx 0rpx rgba(153,153,153,0.22);
display: flex;
justify-content: space-between;
align-items: center;
.public_selector-input{
font-size: 28rpx;
}
.placeholderClass{
color: #505050;
}
}
</style>
\ No newline at end of file
... ...
<template>
<view class="public_switching" :style="{'grid-template-columns': `repeat(${option.length}, 1fr)`}">
<view
@click="selected(item)"
:class="{'public_switching-i': true, 'public_switching-i-c': item.value === current} "
v-for="item in option"
:key="item.value">{{ item.lable }}</view>
</view>
</template>
<script>
export default {
name:"public_switching",
props: {
current: {
type: [String, Number],
default: ''
},
option: {
type: [Array],
default: () => []
}
},
data() {
return {
};
},
methods: {
selected(item) {
this.$emit('change', item.value)
}
}
}
</script>
<style lang="scss" scoped>
.public_switching{
display: grid;
padding: 20rpx 0;
.public_switching-i{
flex-grow: 1;
text-align: center;
color: #F8F8F8;
}
.public_switching-i-c{
color: #F8F8F8;
position: relative;
&::before{
position: absolute;
content: '';
width: 38rpx;
background-color: #fff;
height: 4rpx;
bottom: -20rpx;
left: 50%;
transform: translateX(-50%);
}
}
}
</style>
\ No newline at end of file
... ...
<template>
<view>
<view class="dh_top" :class="bg_img?'cf':''" :style="style+'background-color:'+bg_color">
<image v-if="bg_img" class="nav_bar_img" :src="bg_img" mode="widthFix"></image>
<!-- <text class=""></text>
<text>个人中心</text>
<text class=""></text> -->
<view class="dh_top_box" :style="style1">
<!-- {{bg_img}} -->
<slot></slot>
</view>
</view>
<view v-if="have_top" class="dh_top dh_top1" :style="'height: '+CustomBar+'px;background-color:'+bg_color"></view>
</view>
</template>
<script>
var that
import {
mapState,
mapMutations
} from 'vuex'
export default {
name:"top_bar",
props: {
bg_img:{
type: String,
default: ''
},
bg_color:{
type: String,
default: ''
},
have_top:{
type: Boolean,
default: true
}
},
data() {
return {
StatusBar: this.StatusBar,
CustomBar: this.CustomBar,
};
},
computed: {
...mapState(['hasLogin', 'forcedLogin', 'userName','loginDatas','relation_phone']),
style0() {
var StatusBar = this.StatusBar;
var CustomBar = this.CustomBar;
var padd_top = CustomBar
var style = `padding-top:${padd_top}px;`;
return style
},
style() {
var StatusBar = this.StatusBar;
var CustomBar = this.CustomBar;
var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
return style
},
style1(){
var StatusBar = this.StatusBar;
var style = `top:${StatusBar}px;`;
return style
},
style2(){
var StatusBar = this.StatusBar;
var CustomBar = this.CustomBar;
var style = `padding-top:${CustomBar}px;`;
return style
}
},
methods:{
back(){
uni.navigateBack({
delta:1
})
}
}
}
</script>
<style scoped>
.dh_top{
width: 100vw;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 991;
background-color: #fff;
padding: var(--status-bar-height) 15upx 0;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
overflow: hidden;
box-sizing: border-box;
}
.dh_top1{
opacity: 0;
position: relative;
z-index: 100;
}
.dh_top_box{
position: absolute;
left: 0;
bottom: 0;
right: 0;
margin: auto;
height: 60rpx;
font-size: 32rpx;
/* line-height: 60rpx; */
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 0 15upx;
}
.dh_top>.nav_bar_img{
position: absolute;
top: 0;
left: 0;
right: 0;
width: 100vw;
height: auto;
z-index: 991;
}
.dh_top /deep/ text{
position: relative;
z-index: 992;
color: #333;
}
.cf /deep/ text{
color: #fff;
}
</style>
... ...
<template name="yq-avatar">
<view class="boxsa">
<image :src="imgSrc.imgSrc" @click="fSelect" :style="[ iS ]" class="my-avatar"></image>
<canvas canvas-id="avatar-canvas" id="avatar-canvas" class="my-canvas" :style="{top: sT, height: csH}"
disable-scroll="false"></canvas>
<canvas canvas-id="oper-canvas" id="oper-canvas" class="oper-canvas" :style="{top: sT, height: csH}"
disable-scroll="false" @touchstart="fStart" @touchmove="fMove" @touchend="fEnd"></canvas>
<canvas canvas-id="prv-canvas" id="prv-canvas" class="prv-canvas" disable-scroll="false"
@touchstart="fHideImg" :style="{ height: csH, top: pT }"></canvas>
<view class="oper-wrapper" :style="{display: sD, top:tp}">
<view class="oper">
<view class="btn-wrapper" v-if="sO">
<view @click="fSelect" hover-class="hover" :style="{width: bW}"><text>重选</text></view>
<view @click="fClose" hover-class="hover" :style="{width: bW}"><text>关闭</text></view>
<view @click="fRotate" hover-class="hover" :style="{width: bW, display: bD}"><text>旋转</text></view>
<view @click="fPreview" hover-class="hover" :style="{width: bW}"><text>预览</text></view>
<view @click="fUpload" hover-class="hover" :style="{width: bW}"><text>上传</text></view>
</view>
<view class="clr-wrapper" v-else>
<slider class="my-slider" @change="fColorChange" block-size="25" value="0" min="-100" max="100" activeColor="red"
backgroundColor="green" block-color="grey" show-value></slider>
<view @click="fPrvUpload" hover-class="hover" :style="{width: bW}"><text>上传</text></view>
</view>
</view>
</view>
</view>
</template>
<script>
var that
import {
mapState,
mapMutations
} from 'vuex'
"use strict";
const tH = 50;
export default {
name: "yq-avatar",
data() {
return {
csH: '0px',
sD: 'none',
sT: '-10000px',
pT: '-10000px',
iS: {},
sS: {},
sO: true,
bW: '19%',
bD: 'flex',
tp: 0,
imgSrc: {
imgSrc: ''
}
};
},
onLoad() {
that = this
},
computed: {
...mapState(['hasLogin', 'forcedLogin', 'userName', 'userinfo'])
},
watch: {
avatarSrc() {
this.imgSrc.imgSrc = this.avatarSrc;
}
},
props: {
avatarSrc: '',
avatarStyle: '',
selWidth: '',
selHeight: '',
expWidth: '',
expHeight: '',
minScale: '',
maxScale: '',
canScale: '',
canRotate: '',
lockWidth: '',
lockHeight: '',
stretch: '',
lock: '',
fileType: '',
noTab: '',
inner: '',
quality: '',
index: '',
bgImage: '',
},
created() {
this.cc = uni.createCanvasContext('avatar-canvas', this);
this.cco = uni.createCanvasContext('oper-canvas', this);
this.ccp = uni.createCanvasContext('prv-canvas', this);
this.qlty = parseFloat(this.quality) || 1;
this.imgSrc.imgSrc = this.avatarSrc;
this.letRotate = (this.canRotate === false || this.inner === true || this.inner === 'true' || this.canRotate === 'false') ? 0 : 1;
this.letScale = (this.canScale === false || this.canScale === 'false') ? 0 : 1;
this.isin = (this.inner === true || this.inner === 'true') ? 1 : 0;
this.indx = this.index || undefined;
this.mnScale = parseFloat(this.minScale) || 0.3;
this.mxScale = parseFloat(this.maxScale) || 4;
this.noBar = (this.noTab === true || this.noTab === 'true') ? 1 : 0;
this.stc = this.stretch;
this.lck = this.lock;
this.fType = this.fileType === 'jpg' ? 'jpg' : 'png';
if (this.isin||!this.letRotate) {
this.bW = '24%';
this.bD = 'none';
} else {
this.bW = '19%';
this.bD = 'flex';
}
if (this.noBar) {
this.fWindowResize();
} else {
uni.showTabBar({
fail: ()=>{
this.noBar = 1;
},
success: ()=>{
this.noBar = 0;
},
complete: (res) => {
this.fWindowResize();
}
});
}
},
methods: {
...mapMutations(['logout', 'login']),
getimg(img) {
return this.$service.getimg(img)
},
tiaozhuan(e) {
return this.$service.tiaozhuan(e)
},
fWindowResize() {
let sysInfo = uni.getSystemInfoSync();
this.platform = sysInfo.platform;
this.wW = sysInfo.windowWidth;
// #ifdef H5
this.drawTop = sysInfo.windowTop;
// #endif
// #ifndef H5
this.drawTop = 0;
// #endif
// #ifdef MP-ALIPAY
this.wH = sysInfo.screenHeight - sysInfo.statusBarHeight - sysInfo.titleBarHeight;
this.csH = this.wH - tH + 'px';
// #endif
// #ifndef MP-ALIPAY
this.wH = sysInfo.windowHeight;
if(!this.noBar) this.wH += tH;
this.csH = this.wH - tH + 'px';
// #endif
this.tp = this.csH;
// #ifdef H5
this.tp = sysInfo.windowTop + parseInt(this.csH)+ 'px';
// #endif
this.pxRatio = this.wW / 750;
let style = this.avatarStyle;
if (style && style !== true && (style = style.trim())) {
style = style.split(';');
let obj = {};
for (let v of style) {
if (!v) continue;
v = v.trim().split(':');
if (v[1].toString().indexOf('upx') >= 0) {
let arr = v[1].trim().split(' ');
for (let k in arr) {
if (!arr[k]) continue;
if (arr[k].toString().indexOf('upx') >= 0) {
arr[k] = parseFloat(arr[k]) * this.pxRatio + 'px';
}
}
v[1] = arr.join(' ');
}
obj[v[0].trim()] = v[1].trim();
}
this.iS = obj;
}
this.expWidth && (this.eW = this.expWidth.toString().indexOf('upx') >= 0 ? parseInt(this.expWidth) * this.pxRatio :
parseInt(this.expWidth));
this.expHeight && (this.eH = this.expHeight.toString().indexOf('upx') >= 0 ? parseInt(this.expHeight) * this.pxRatio :
parseInt(this.expHeight));
if (this.sD === 'flex') {
this.fDrawInit(true);
}
this.fHideImg();
},
fSelect() {
if (this.fSelecting) return;
this.fSelecting = true;
setTimeout(() => {
this.fSelecting = false;
}, 500);
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: (r) => {
// #ifdef MP-ALIPAY
uni.showLoading();
// #endif
// #ifndef MP-ALIPAY
uni.showLoading({
title: '加载中...',
mask: true
});
// #endif
let path = this.imgPath = r.tempFilePaths[0];
uni.getImageInfo({
src: path,
success: r => {
this.imgWidth = r.width;
this.imgHeight = r.height;
this.path = path;
if (!this.hasSel) {
let style = this.sS || {};
if (this.selWidth && this.selHeight) {
let sW = this.selWidth.toString().indexOf('upx') >= 0 ? parseInt(this.selWidth) * this.pxRatio : parseInt(
this.selWidth),
sH = this.selHeight.toString().indexOf('upx') >= 0 ? parseInt(this.selHeight) * this.pxRatio : parseInt(
this.selHeight);
style.width = sW + 'px';
style.height = sH + 'px';
style.top = ((this.wH - sH - tH)|0) / 2 + 'px';
style.left = ((this.wW - sW)|0) / 2 + 'px';
} else {
uni.showModal({
title: '裁剪框的宽或高没有设置',
showCancel: false
})
return;
}
this.sS = style;
}
if (this.noBar) {
this.fDrawInit(true);
} else {
uni.hideTabBar({
complete: () => {
this.fDrawInit(true);
}
});
}
},
fail: () => {
uni.showToast({
title: "请选择正确图片",
icon:'none',
duration: 2000,
})
},
complete() {
uni.hideLoading();
}
});
}
})
},
fUpload() {
if (this.fUploading) return;
this.fUploading = true;
setTimeout(() => {
this.fUploading = false;
}, 1000)
let style = this.sS,
x = parseInt(style.left),
y = parseInt(style.top),
width = parseInt(style.width),
height = parseInt(style.height),
expWidth = this.eW || (width* this.pixelRatio),
expHeight = this.eH || (height* this.pixelRatio);
// #ifdef MP-ALIPAY
uni.showLoading();
// #endif
// #ifndef MP-ALIPAY
uni.showLoading({
title: '加载中...',
mask: true
});
// #endif
this.sD = 'none';
this.sT = '-10000px';
this.hasSel = false;
this.fHideImg();
// #ifdef MP-ALIPAY
this.cc.toTempFilePath({
x: x,
y: y,
width: width,
height: height,
destWidth: expWidth,
destHeight: expHeight,
fileType: this.fType,
quality: this.qlty,
success: (r) => {
r = r.apFilePath;
this.$emit("upload", {
avatar: this.imgSrc,
path: r,
index: this.indx,
data: this.rtn,
base64: this.base64 || null
});
},
fail: (res) => {
uni.showToast({
title: "error1",
duration: 2000,
})
},
complete: () => {
uni.hideLoading();
this.noBar || uni.showTabBar();
this.$emit("end");
}
});
// #endif
// #ifndef MP-ALIPAY
uni.canvasToTempFilePath({
x: x,
y: y,
width: width,
height: height,
destWidth: expWidth,
destHeight: expHeight,
canvasId: 'avatar-canvas',
fileType: this.fType,
quality: this.qlty,
success: (r) => {
r = r.tempFilePath;
// #ifdef H5
this.btop(r).then((r) => {
this.$emit("upload", {
avatar: this.imgSrc,
path: r,
index: this.indx,
data: this.rtn,
base64: this.base64 || null
});
return;
})
// #endif
// #ifndef H5
this.$emit("upload", {
avatar: this.imgSrc,
path: r,
index: this.indx,
data: this.rtn,
base64: this.base64 || null
});
// #endif
},
fail: (res) => {
uni.showToast({
title: "error1",
duration: 2000,
})
},
complete: () => {
uni.hideLoading();
this.noBar || uni.showTabBar();
this.$emit("end");
}
}, this);
// #endif
},
fPrvUpload() {
if (this.fPrvUploading) return;
this.fPrvUploading = true;
setTimeout(() => {
this.fPrvUploading = false;
}, 1000)
// console.log(this.fPrvUploading)
let style = this.sS,
destWidth = parseInt(style.width),
destHeight = parseInt(style.height),
prvX = this.prvX,
prvY = this.prvY,
prvWidth = this.prvWidth,
prvHeight = this.prvHeight,
expWidth = this.eW || (parseInt(style.width) * this.pixelRatio),
expHeight = this.eH || (parseInt(style.height) * this.pixelRatio);
// #ifdef MP-ALIPAY
uni.showLoading();
// #endif
// #ifndef MP-ALIPAY
uni.showLoading({
title: '加载中...',
mask: true
});
// #endif
this.sD = 'none';
this.sT = '-10000px';
this.hasSel = false;
this.fHideImg();
// #ifdef MP-ALIPAY
this.ccp.toTempFilePath({
x: prvX,
y: prvY,
width: prvWidth,
height: prvHeight,
destWidth: expWidth,
destHeight: expHeight,
fileType: this.fType,
quality: this.qlty,
success: (r) => {
r = r.apFilePath;
this.$emit("upload", {
avatar: this.imgSrc,
path: r,
index: this.indx,
data: this.rtn,
base64: this.base64 || null
});
},
fail: () => {
uni.showToast({
title: "error_prv",
duration: 2000,
})
},
complete: () => {
uni.hideLoading();
this.noBar || uni.showTabBar();
this.$emit("end");
},
});
// #endif
// #ifndef MP-ALIPAY
uni.canvasToTempFilePath({
x: prvX,
y: prvY,
width: prvWidth,
height: prvHeight,
destWidth: expWidth,
destHeight: expHeight,
canvasId: 'prv-canvas',
fileType: this.fType,
quality: this.qlty,
success: (r) => {
r = r.tempFilePath;
// #ifdef H5
this.btop(r).then((r) => {
this.$emit("upload", {
avatar: this.imgSrc,
path: r,
index: this.indx,
data: this.rtn,
base64: this.base64 || null
});
})
// #endif
// #ifndef H5
this.$emit("upload", {
avatar: this.imgSrc,
path: r,
index: this.indx,
data: this.rtn,
base64: this.base64 || null
});
// #endif
},
fail: () => {
uni.showToast({
title: "error_prv",
duration: 2000,
})
},
complete: () => {
uni.hideLoading();
this.noBar || uni.showTabBar();
this.$emit("end");
}
}, this);
// #endif
},
fDrawInit(ini = false) {
let allWidth = this.wW,
allHeight = this.wH,
imgWidth = this.imgWidth,
imgHeight = this.imgHeight,
imgRadio = imgWidth / imgHeight,
useWidth = allWidth - 40,
useHeight = allHeight - tH - 80,
useRadio = useWidth / useHeight,
sW = parseInt(this.sS.width),
sH = parseInt(this.sS.height);
this.fixWidth = 0;
this.fixHeight = 0;
this.lckWidth = 0;
this.lckHeight = 0;
switch (this.stc) {
case 'x':
this.fixWidth = 1;
break;
case 'y':
this.fixHeight = 1;
break;
case 'long':
if (imgRadio > 1) this.fixWidth = 1;
else this.fixHeight = 1;
break;
case 'short':
if (imgRadio > 1) this.fixHeight = 1;
else this.fixWidth = 1;
break;
case 'longSel':
if (sW > sH) this.fixWidth = 1;
else this.fixHeight = 1;
break;
case 'shortSel':
if (sW > sH) this.fixHeight = 1;
else this.fixWidth = 1;
break;
}
switch (this.lck) {
case 'x':
this.lckWidth = 1;
break;
case 'y':
this.lckHeight = 1;
break;
case 'long':
if (imgRadio > 1) this.lckWidth = 1;
else this.lckHeight = 1;
break;
case 'short':
if (imgRadio > 1) this.lckHeight = 1;
else this.lckWidth = 1;
break;
case 'longSel':
if (sW > sH) this.lckWidth = 1;
else this.lckHeight = 1;
break;
case 'shortSel':
if (sW > sH) this.lckHeight = 1;
else this.lckWidth = 1;
break;
}
if (this.fixWidth) {
useWidth = sW;
useHeight = useWidth / imgRadio;
} else if (this.fixHeight) {
useHeight = sH;
useWidth = useHeight * imgRadio;
} else if (imgRadio < useRadio) {
if (imgHeight < useHeight) {
useWidth = imgWidth;
useHeight = imgHeight;
} else {
useWidth = useHeight * imgRadio;
}
} else {
if (imgWidth < useWidth) {
useWidth = imgWidth;
useHeight = imgHeight;
} else {
useHeight = useWidth / imgRadio;
}
}
if (this.isin) {
if (useWidth < sW) {
useWidth = sW;
useHeight = useWidth / imgRadio;
this.lckHeight = 0;
}
if (useHeight < sH) {
useHeight = sH;
useWidth = useHeight * imgRadio;
this.lckWidth = 0;
}
}
this.scaleSize = 1;
this.rotateDeg = 0;
this.posWidth = (allWidth - useWidth) / 2 | 0;
this.posHeight = (allHeight - useHeight - tH) / 2 | 0;
this.useWidth = useWidth | 0;
this.useHeight = useHeight | 0;
this.centerX = this.posWidth + useWidth / 2;
this.centerY = this.posHeight + useHeight / 2;
this.focusX = 0;
this.focusY = 0;
let style = this.sS,
left = parseInt(style.left),
top = parseInt(style.top),
width = parseInt(style.width),
height = parseInt(style.height),
canvas = this.canvas,
canvasOper = this.canvasOper,
cc = this.cc,
cco = this.cco;
cco.beginPath();
cco.setLineWidth(3);
cco.setGlobalAlpha(1);
cco.setStrokeStyle('white');
cco.strokeRect(left, top, width, height);
cco.setFillStyle('black');
cco.setGlobalAlpha(0.5);
cco.fillRect(0, 0, this.wW, top);
cco.fillRect(0, top, left, height);
cco.fillRect(0, top + height, this.wW, this.wH - height - top - tH);
cco.fillRect(left + width, top, this.wW - width - left, height);
cco.setGlobalAlpha(1);
cco.setStrokeStyle('red');
cco.moveTo(left+15, top);
cco.lineTo(left, top);
cco.lineTo(left, top+15);
cco.moveTo(left+width-15, top);
cco.lineTo(left+width, top);
cco.lineTo(left+width, top+15);
cco.moveTo(left+15, top+height);
cco.lineTo(left, top+height);
cco.lineTo(left, top+height-15);
cco.moveTo(left+width-15, top+height);
cco.lineTo(left+width, top+height);
cco.lineTo(left+width, top+height-15);
cco.stroke();
cco.draw(false, () => {
if (ini) {
this.sD = 'flex';
this.sT = this.drawTop + 'px';
this.fDrawImage(true);
}
});
this.$emit("init");
},
fDrawImage(ini = false) {
let tm_now = Date.now();
if (tm_now - this.drawTm < 20) return;
this.drawTm = tm_now;
let cc = this.cc,
imgWidth = this.useWidth * this.scaleSize,
imgHeight = this.useHeight * this.scaleSize;
// #ifdef MP-ALIPAY
cc.save();
// #endif
if (this.bgImage) {
// #ifdef MP-ALIPAY
cc.clearRect(0, 0, this.wW, this.wH - tH);
// #endif
// #ifndef MP-ALIPAY
cc.drawImage(this.bgImage, 0, 0, this.wW, this.wH - tH);
// #endif
} else {
cc.fillRect(0, 0, this.wW, this.wH - tH);
}
if (this.isin) {
let cx = this.focusX * (this.scaleSize - 1),
cy = this.focusY * (this.scaleSize - 1);
cc.translate(this.centerX, this.centerY);
cc.rotate(this.rotateDeg * Math.PI / 180);
cc.drawImage(this.imgPath, this.posWidth-this.centerX-cx, this.posHeight-this.centerY-cy, imgWidth, imgHeight);
} else {
cc.translate(this.posWidth + imgWidth / 2, this.posHeight + imgHeight / 2);
cc.rotate(this.rotateDeg * Math.PI / 180);
cc.drawImage(this.imgPath, -imgWidth / 2, -imgHeight / 2, imgWidth, imgHeight);
}
cc.draw(false);
// #ifdef MP-ALIPAY
cc.restore();
// #endif
},
fPreview() {
if (this.fPreviewing) return;
this.fPreviewing = true;
setTimeout(() => {
this.fPreviewing = false;
}, 1000);
let style = this.sS,
x = parseInt(style.left),
y = parseInt(style.top),
width = parseInt(style.width),
height = parseInt(style.height);
// #ifdef MP-ALIPAY
uni.showLoading();
// #endif
// #ifndef MP-ALIPAY
uni.showLoading({
title: '加载中...',
mask: true
});
// #endif
// #ifdef MP-ALIPAY
this.cc.toTempFilePath({
x: x,
y: y,
width: width,
height: height,
expWidth: width * this.pixelRatio,
expHeight: height * this.pixelRatio,
fileType: this.fType,
quality: this.qlty,
success: (r) => {
this.prvImgTmp = r = r.apFilePath;
let ccp = this.ccp,
prvX = this.wW,
prvY = parseInt(this.csH),
prvWidth = parseInt(this.sS.width),
prvHeight = parseInt(this.sS.height),
useWidth = prvX - 40,
useHeight = prvY - 80,
radio = useWidth / prvWidth,
rHeight = prvHeight * radio;
if (rHeight < useHeight) {
prvWidth = useWidth;
prvHeight = rHeight;
} else {
radio = useHeight / prvHeight;
prvWidth *= radio;
prvHeight = useHeight;
}
ccp.fillRect(0, 0, prvX, prvY);
this.prvX = prvX = ((prvX - prvWidth) / 2) | 0;
this.prvY = prvY = ((prvY - prvHeight) / 2) | 0;
this.prvWidth = prvWidth = prvWidth | 0;
this.prvHeight = prvHeight = prvHeight | 0;
ccp.drawImage(r, prvX, prvY, prvWidth, prvHeight);
ccp.draw(false);
this.sO = false;
this.pT = '0';
},
fail: () => {
uni.showToast({
title: "error2",
duration: 2000,
})
},
complete: () => {
uni.hideLoading();
}
});
// #endif
// #ifndef MP-ALIPAY
uni.canvasToTempFilePath({
x: x,
y: y,
width: width,
height: height,
expWidth: width * this.pixelRatio,
expHeight: height * this.pixelRatio,
canvasId: 'avatar-canvas',
fileType: this.fType,
quality: this.qlty,
success: (r) => {
this.prvImgTmp = r = r.tempFilePath;
let ccp = this.ccp,
prvX = this.wW,
prvY = parseInt(this.csH);
// #ifndef H5||MP-WEIXIN||APP-PLUS
prvY += tH;
// #endif
// #ifdef APP-PLUS
if (this.platform === 'android') {
prvY += tH;
}
// #endif
let prvWidth = parseInt(this.sS.width),
prvHeight = parseInt(this.sS.height),
useWidth = prvX - 40,
useHeight = prvY - 80,
radio = useWidth / prvWidth,
rHeight = prvHeight * radio;
if (rHeight < useHeight) {
prvWidth = useWidth;
prvHeight = rHeight;
} else {
radio = useHeight / prvHeight;
prvWidth *= radio;
prvHeight = useHeight;
}
ccp.fillRect(0, 0, prvX, prvY);
this.prvX = prvX = ((prvX - prvWidth) / 2) | 0;
this.prvY = prvY = ((prvY - prvHeight) / 2) | 0;
this.prvWidth = prvWidth = prvWidth | 0;
this.prvHeight = prvHeight = prvHeight | 0;
ccp.drawImage(r, prvX, prvY, prvWidth, prvHeight);
ccp.draw(false);
// #ifdef H5
this.btop(r).then((r) => {
this.sO = false;
this.pT = this.drawTop + 'px';
})
// #endif
this.sO = false;
// if (this.platform === 'android') this.sO = false;
this.pT = this.drawTop + 'px';
},
fail: () => {
uni.showToast({
title: "error2",
duration: 2000,
})
},
complete: () => {
uni.hideLoading();
}
}, this);
// #endif
},
fChooseImg(index = undefined, params = undefined, data = undefined) {
if (params) {
let sW = params.selWidth,
sH = params.selHeight,
expWidth = params.expWidth,
expHeight = params.expHeight,
quality = params.quality,
canRotate = params.canRotate,
canScale = params.canScale,
minScale = params.minScale,
maxScale = params.maxScale,
stretch = params.stretch,
fileType = params.fileType,
inner = params.inner,
lock = params.lock;
expWidth && (this.eW = expWidth.toString().indexOf('upx') >= 0 ? parseInt(expWidth) * this.pxRatio : parseInt(
expWidth));
expHeight && (this.eH = expHeight.toString().indexOf('upx') >= 0 ? parseInt(expHeight) * this.pxRatio : parseInt(
expHeight));
this.letRotate = (canRotate === false || inner === true || inner === 'true' || canRotate === 'false') ? 0 : 1;
this.letScale = (canScale === false || canScale === 'false') ? 0 : 1;
this.qlty = parseFloat(quality) || 1;
this.mnScale = parseFloat(minScale) || 0.3;
this.mxScale = parseFloat(maxScale) || 4;
this.stc = stretch;
this.isin = (inner === true || inner === 'true') ? 1 : 0;
this.fType = fileType === 'jpg' ? 'jpg' : 'png';
this.lck = lock;
if (this.isin||!this.letRotate) {
this.bW = '24%';
this.bD = 'none';
} else {
this.bW = '19%';
this.bD = 'flex';
}
if (sW && sH) {
sW = sW.toString().indexOf('upx') >= 0 ? parseInt(sW) * this.pxRatio : parseInt(sW);
sH = sH.toString().indexOf('upx') >= 0 ? parseInt(sH) * this.pxRatio : parseInt(sH);
this.sS.width = sW + 'px';
this.sS.height = sH + 'px';
this.sS.top = ((this.wH - sH - tH)|0) / 2 + 'px';
this.sS.left = ((this.wW - sW)|0) / 2 + 'px';
this.hasSel = true;
}
}
this.rtn = data;
this.indx = index;
this.fSelect();
},
fRotate() {
this.rotateDeg += 90 - this.rotateDeg % 90;
this.fDrawImage();
},
fStart(e) {
let touches = e.touches,
touch0 = touches[0],
touch1 = touches[1];
this.touch0 = touch0;
this.touch1 = touch1;
if (touch1) {
let x = touch1.x - touch0.x,
y = touch1.y - touch0.y;
this.fgDistance = Math.sqrt(x * x + y * y);
}
},
fMove(e) {
let touches = e.touches,
touch0 = touches[0],
touch1 = touches[1];
if (touch1) {
let x = touch1.x - touch0.x,
y = touch1.y - touch0.y,
fgDistance = Math.sqrt(x * x + y * y),
scaleSize = 0.005 * (fgDistance - this.fgDistance),
beScaleSize = this.scaleSize + scaleSize;
do {
if (!this.letScale) break;
if (beScaleSize < this.mnScale) break;
if (beScaleSize > this.mxScale) break;
let growX = this.useWidth * scaleSize / 2,
growY = this.useHeight * scaleSize / 2;
if (this.isin) {
let imgWidth = this.useWidth * beScaleSize,
imgHeight = this.useHeight * beScaleSize,
l = this.posWidth - growX,
t = this.posHeight - growY,
r = l + imgWidth,
b = t + imgHeight,
left = parseInt(this.sS.left),
top = parseInt(this.sS.top),
width = parseInt(this.sS.width),
height = parseInt(this.sS.height),
right = left + width,
bottom = top + height,
cx, cy;
if (imgWidth <= width || imgHeight <= height) break;
this.cx = cx = this.focusX * beScaleSize - this.focusX,
this.cy = cy = this.focusY * beScaleSize - this.focusY;
this.posWidth -= growX;
this.posHeight -= growY;
if (this.posWidth - cx > left) {
this.posWidth = left + cx;
}
if (this.posWidth + imgWidth - cx < right) {
this.posWidth = right - imgWidth + cx;
}
if (this.posHeight - cy > top) {
this.posHeight = top + cy;
}
if (this.posHeight + imgHeight - cy < bottom) {
this.posHeight = bottom - imgHeight + cy;
}
} else {
this.posWidth -= growX;
this.posHeight -= growY;
}
this.scaleSize = beScaleSize;
} while (0);
this.fgDistance = fgDistance;
if (touch1.x !== touch0.x && this.letRotate) {
x = (this.touch1.y - this.touch0.y) / (this.touch1.x - this.touch0.x);
y = (touch1.y - touch0.y) / (touch1.x - touch0.x);
this.rotateDeg += Math.atan((y - x) / (1 + x * y)) * 180 / Math.PI;
this.touch0 = touch0;
this.touch1 = touch1;
}
this.fDrawImage();
} else if (this.touch0) {
let x = touch0.x - this.touch0.x,
y = touch0.y - this.touch0.y,
beX = this.posWidth + x,
beY = this.posHeight + y;
if (this.isin) {
let imgWidth = this.useWidth * this.scaleSize,
imgHeight = this.useHeight * this.scaleSize,
l = beX,
t = beY,
r = l + imgWidth,
b = t + imgHeight,
left = parseInt(this.sS.left),
top = parseInt(this.sS.top),
right = left + parseInt(this.sS.width),
bottom = top + parseInt(this.sS.height),
cx, cy;
this.cx = cx = this.focusX * this.scaleSize - this.focusX;
this.cy = cy = this.focusY * this.scaleSize - this.focusY;
if (!this.lckWidth && Math.abs(x) < 100) {
if (left < l - cx) {
this.posWidth = left + cx;
} else if (right > r - cx) {
this.posWidth = right - imgWidth + cx;
} else {
this.posWidth = beX;
this.focusX -= x;
}
}
if (!this.lckHeight && Math.abs(y) < 100) {
if (top < t - cy) {
this.focusY -= (top + cy - this.posHeight);
this.posHeight = top + cy;
} else if (bottom > b - cy) {
this.focusY -= (bottom + cy - (this.posHeight + imgHeight));
this.posHeight = bottom - imgHeight + cy;
} else {
this.posHeight = beY;
this.focusY -= y;
}
}
} else {
if (Math.abs(x) < 100 && !this.lckWidth) this.posWidth = beX;
if (Math.abs(y) < 100 && !this.lckHeight) this.posHeight = beY;
this.focusX -= x;
this.focusY -= y;
}
this.touch0 = touch0;
this.fDrawImage();
}
},
fEnd(e) {
let touches = e.touches,
touch0 = touches && touches[0],
touch1 = touches && touches[1];
if (touch0) {
this.touch0 = touch0;
} else {
this.touch0 = null;
this.touch1 = null;
}
},
fHideImg() {
this.prvImg = '';
this.pT = '-10000px';
this.sO = true;
this.prvImgData = null;
this.target = null;
},
fClose() {
this.sD = 'none';
this.sT = '-10000px';
this.hasSel = false;
this.fHideImg();
this.noBar || uni.showTabBar();
this.$emit("end");
},
fGetImgData() {
return new Promise((resolve, reject) => {
let prvX = this.prvX,
prvY = this.prvY,
prvWidth = this.prvWidth,
prvHeight = this.prvHeight;
// #ifdef MP-ALIPAY
this.ccp.getImageData({
x: prvX,
y: prvY,
width: prvWidth,
height: prvHeight,
success(res) {
resolve(res.data);
},
fail(err) {
reject(err);
}
}, this);
// #endif
// #ifndef MP-ALIPAY
uni.canvasGetImageData({
canvasId: 'prv-canvas',
x: prvX,
y: prvY,
width: prvWidth,
height: prvHeight,
success(res) {
resolve(res.data);
},
fail(err) {
reject(err);
}
}, this);
// #endif
});
},
async fColorChange(e) {
let tm_now = Date.now();
if (tm_now - this.prvTm < 100) return;
this.prvTm = tm_now;
// #ifdef MP-ALIPAY
uni.showLoading();
// #endif
// #ifndef MP-ALIPAY
uni.showLoading({
title: '加载中...',
mask: true
});
// #endif
if (!this.prvImgData) {
if (!(this.prvImgData = await this.fGetImgData().catch(() => {
uni.showToast({
title: "error_read",
duration: 2000,
})
}))) return;
this.target = new Uint8ClampedArray(this.prvImgData.length);
}
let data = this.prvImgData,
target = this.target,
i = e.detail.value,
r, g, b, a, h, s, l, d, p, q, t, min, max, hK, tR, tG, tB;
if (i === 0) {
target = data;
} else {
i = (i + 100) / 200;
if (i < 0.005) i = 0;
if (i > 0.995) i = 1;
for (let n = data.length - 1; n >= 0; n -= 4) {
r = data[n - 3] / 255;
g = data[n - 2] / 255;
b = data[n - 1] / 255;
max = Math.max(r, g, b);
min = Math.min(r, g, b);
d = max - min;
if (max === min) {
h = 0;
} else if (max === r && g >= b) {
h = 60 * ((g - b) / d);
} else if (max === r && g < b) {
h = 60 * ((g - b) / d) + 360;
} else if (max === g) {
h = 60 * ((b - r) / d) + 120;
} else if (max === b) {
h = 60 * ((r - g) / d) + 240;
}
l = (max + min) / 2;
if (l === 0 || max === min) {
s = 0;
} else if (0 < l && l <= 0.5) {
s = d / (2 * l);
} else if (l > 0.5) {
s = d / (2 - 2 * l);
}
data[n] && (a = data[n]);
if (i < 0.5) {
s = s * i / 0.5;
} else if (i > 0.5) {
s = 2 * s + 2 * i - (s * i / 0.5) - 1;
}
if (s === 0) {
r = g = b = Math.round(l * 255);
} else {
if (l < 0.5) {
q = l * (1 + s);
} else if (l >= 0.5) {
q = l + s - (l * s);
}
p = 2 * l - q;
hK = h / 360;
tR = hK + 1 / 3;
tG = hK;
tB = hK - 1 / 3;
let correctRGB = (t) => {
if (t < 0) {
return t + 1.0;
}
if (t > 1) {
return t - 1.0;
}
return t;
};
let createRGB = (t) => {
if (t < (1 / 6)) {
return p + ((q - p) * 6 * t);
} else if (t >= (1 / 6) && t < (1 / 2)) {
return q;
} else if (t >= (1 / 2) && t < (2 / 3)) {
return p + ((q - p) * 6 * ((2 / 3) - t));
}
return p;
};
r = tR = Math.round(createRGB(correctRGB(tR)) * 255);
g = tG = Math.round(createRGB(correctRGB(tG)) * 255);
b = tB = Math.round(createRGB(correctRGB(tB)) * 255);
}
a && (target[n] = a);
target[n - 3] = r;
target[n - 2] = g;
target[n - 1] = b;
}
}
let prvX = this.prvX,
prvY = this.prvY,
prvWidth = this.prvWidth,
prvHeight = this.prvHeight;
// #ifdef MP-ALIPAY
this.ccp.putImageData({
x: prvX,
y: prvY,
width: prvWidth,
height: prvHeight,
data: target,
fail() {
uni.showToast({
title: 'error_put',
duration: 2000
})
},
complete() {
uni.hideLoading();
}
}, this);
// #endif
// #ifndef MP-ALIPAY
uni.canvasPutImageData({
canvasId: 'prv-canvas',
x: prvX,
y: prvY,
width: prvWidth,
height: prvHeight,
data: target,
fail() {
uni.showToast({
title: 'error_put',
duration: 2000
})
},
complete() {
uni.hideLoading();
}
}, this);
// #endif
},
btop(base64) {
this.base64 = base64;
return new Promise(function(resolve, reject) {
var arr = base64.split(','),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return resolve((window.URL || window.webkitURL).createObjectURL(new Blob([u8arr], {
type: mime
})));
});
},
}
}
</script>
<style>
.boxsa{
z-index: 800;
}
.my-canvas {
display: flex;
position: fixed !important;
background: #000000;
left: 0;
z-index: 100000;
width: 100%;
}
.my-avatar {
width: 150upx;
height: 150upx;
border-radius: 100%;
}
.oper-canvas {
display: flex;
position: fixed !important;
left: 0;
z-index: 100001;
width: 100%;
}
.prv-canvas {
display: flex;
position: fixed !important;
background: #000000;
left: 0;
z-index: 200000;
width: 100%;
}
.oper-wrapper {
height: 50px;
position: fixed !important;
box-sizing: border-box;
border: 1px solid #F1F1F1;
background: #ffffff;
width: 100%;
left: 0;
bottom: 0;
z-index: 100009;
flex-direction: row;
}
.oper {
display: flex;
flex-direction: column;
justify-content: center;
padding: 10upx 20upx;
width: 100%;
height: 100%;
box-sizing: border-box;
align-self: center;
}
.btn-wrapper {
display: flex;
flex-direction: row;
/* #ifndef H5 */
flex-grow: 1;
/* #endif */
/* #ifdef H5 */
height: 50px;
/* #endif */
justify-content: space-between;
}
.btn-wrapper view {
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
color: #333;
border: 1px solid #f1f1f1;
border-radius: 6%;
}
.hover {
background: #f1f1f1;
border-radius: 6%;
}
.clr-wrapper {
display: flex;
flex-direction: row;
flex-grow: 1;
}
.clr-wrapper view {
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
color: #333;
border: 1px solid #f1f1f1;
border-radius: 6%;
}
.my-slider {
flex-grow: 1;
}
</style>
... ...
/**
* 点赞类型
*/
export const LIKETYPE = {
/**
* 学生端
* @value STUDENTEND
*/
'STUDENTEND': 'STUDENTEND',
/**
* 老师端
* @value TEACHERSEND
*/
'TEACHERSEND': 'TEACHERSEND',
/**
* 管理员端
* @value ADMINEND
*/
'ADMINEND': 'ADMINEND'
}
/**
* 性别类型
*/
export const GENDER = {
/**
* 男
* @value 1
*/
"MALE": 1,
/**
* 女
* @value 2
*/
"FEMALE": 2
}
/**
* 操作状态
*/
export const OPERATIONSTATUS = {
/**
* 待审核
* @value 0
*/
'PENDINGREVIEW': 0,
/**
* 通过
* @value 1
*/
'ADOPT': 1,
/**
* 不通过
* @value 2
*/
'REFUSE': 2
}
/**
* 请假审核状态
*/
export const AUDITSTATUS = {
/**
* 待审核
* @value 1
*/
'PENDINGREVIEW': 1,
/**
* 审核通过
* @value 2
*/
'APPROVED': 2,
/**
* 未通过
* @value 3
*/
'FAILED': 3
}
\ No newline at end of file
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<!--preload-links-->
<!--app-context-->
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
</body>
</html>
... ...
import Vue from 'vue'
import App from './App'
import service from "@/common/service.js"
import store from './store'
// 导入并挂载全局的分享方法
import share from '@/common/share.js'
Vue.mixin(share)
// (ID):wx5bbc433d447d1a86
// (密钥):7fc1344c96e987638638f9fd9701346b
//导入自己封装的类库
// import sjuAsync from './common/sju.async.js'
// import sjuBase from './common/sju.base.js'
// import sjuAlert from './common/sju.alert.js'
// import sjuLogin from './common/sju.login.js'
// import sjuAjax from './common/sju.ajax.js'
// import sjuPay from './common/sju.pay.js'
import sjuNav from './common/sju.nav.js'
// 将封装库引入Vue原型链
// Vue.prototype.$sjuAsync = sjuAsync;
// Vue.prototype.$sjuBase = sjuBase;
// Vue.prototype.$sjuAlert = sjuAlert;
// Vue.prototype.$sjuLogin = sjuLogin;
// Vue.prototype.$sjuAjax = sjuAjax;
// Vue.prototype.$sjuPay = sjuPay;
// 引入全局uView
import uView from 'uview-ui'
Vue.use(uView);
import topbar from './components/top_bar/top_bar.vue'
Vue.component('topbar',topbar)
import ftadd from './components/ft_add/ft_add.vue'
Vue.component('ftadd',ftadd)
import ftadd1 from './components/ft_add/ft_add1.vue'
Vue.component('ftadd1',ftadd1)
// 剪裁头像
import avatar from "./components/yq-avatar/yq-avatar.vue";
// Vue.prototype.$url = url
Vue.component('avatar',avatar)
// 图片懒加载
import myLazyLoad from "./components/my_lazy_load/my_lazy_load.vue";
// Vue.prototype.$url = url
Vue.component('myLazyLoad',myLazyLoad)
Vue.prototype.$sjuNav = sjuNav //页面跳转
Vue.prototype.$service = service;
Vue.prototype.$store = store
// Vue.prototype.$service = service
App.mpType = 'app'
const app = new Vue({
store,
...App
})
app.$mount()
... ...
{
"name" : "teaching",
"appid" : "__UNI__C551C4D",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
/* 模块配置 */
"modules" : {},
/* 应用发布信息 */
"distribute" : {
/* android打包配置 */
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios打包配置 */
"ios" : {},
/* SDK配置 */
"sdkConfigs" : {}
}
},
/* 快应用特有相关 */
"quickapp" : {},
/* 小程序特有相关 */
"mp-weixin" : {
"appid" : "wx5bbc433d447d1a86",
"setting" : {
"urlCheck" : false,
"es6" : true
},
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "2"
}
... ...
<template>
<view class="add_praise">
<view class="tel_index_bg"></view>
<view class="add_praise-main">
<view class="add_praise-main-1">
<view class="add_praise-main-1-l">请在此处提交你对我校及某位老师的表扬</view>
<view class="add_praise-main-1-b">
<view class="add_praise-main-1-b-u">
<u-upload
:fileList="fileList"
@afterRead="afterRead"
@delete="deletePic"
name="4"
multiple
:maxCount="6"
></u-upload>
</view>
<view class="add_praise-main-1-b-t">
<u--textarea height="150" v-model="content" placeholder="请输入文字内容" ></u--textarea>
</view>
</view>
</view>
<view class="operation" @click="submit">
提交表扬
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
fileList: [],
content: ''
};
},
methods: {
submit() {
var datas = {
content: this.content,
imgs: this.fileList.map(item => item.url)
}
var jkurl = '/praise/add'
this.$service.P_post(jkurl, datas).then(res => {
uni.showToast({
icon:'none',
title: '上传成功'
})
setTimeout(() => {
uni.navigateBack({
delta: 1
})
}, 1500)
})
},
async afterRead(event) {
let lists = [].concat(event.file)
for (let i = 0; i < lists.length; i++) {
let res = await this.uploadFilePromise(lists[i].url)
this.fileList.push({
name: res.data,
url: res.name
})
}
this.$emit('change', this.fileList)
},
uploadFilePromise(url) {
let baseurl = this.$service.baseurl
return new Promise((resolve, reject) => {
uni.showLoading({
title: '上传中'
})
uni.uploadFile({
url: baseurl + 'api/login/upload', // 仅为示例,非真实的接口地址
filePath: url,
name: 'file',
header: {
'Authorization': uni.getStorageSync('token')
},
formData: {},
success: (res) => {
console.log('res=====>', JSON.parse(res.data))
resolve(JSON.parse(res.data))
uni.hideLoading()
}
});
})
},
deletePic(e) {
console.log(e.index)
this.fileList.splice(0, 1)
}
}
}
</script>
<style lang="scss">
.add_praise{
.tel_index_bg{
position: absolute;
top: 0;
z-index: 1;
width: 100%;
min-height: 220rpx;
background: linear-gradient(0deg, #f8f8f8 0%, #ffffff 25%, #5D9DFD 60%, #428EFE 70%, #2D81FF 100%);
}
.add_praise-main{
position: relative;
z-index: 1;
padding: 15rpx 25rpx;
.add_praise-main-1{
border-radius: 15rpx;
background: #fff;
overflow: hidden;
.add_praise-main-1-l{
line-height: 60rpx;
padding: 0 30rpx;
background: #fff9eb;
color: #F5AC1A;
font-size: 24rpx;
}
.add_praise-main-1-b{
padding: 0rpx 30rpx;
.add_praise-main-1-b-u{
padding: 40rpx 0rpx;
border-bottom: #EEEEEE solid 1rpx;
}
}
}
.operation{
border-radius: 15rpx;
background-color: #2C82FD;
line-height: 90rpx;
text-align: center;
width: 700rpx;
color: #fff;
z-index: 1;
margin-top: 40rpx;
}
}
}
</style>
... ...
<template>
<view class="admin_praise">
<view class="tel_index_bg"></view>
<view class="admin_praise-main">
<public-switching :option="option" :current="current" @change="changeSwitching"></public-switching>
<scroll-view :scroll-y="true" class="praise_andLike-list" @scrolltolower="getData">
<view v-if="dataList.length">
<praise-item :type="LIKETYPE.ADMINEND" :info="item" v-for="item in dataList" :key="item.id" @success="success"></praise-item>
</view>
<u-empty v-else mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" ></u-empty>
</scroll-view>
</view>
</view>
</template>
<script>
import public_switching from "@/components/public_switching/public_switching.vue"
import praise_item from "@/components/praise_item/praise_item.vue"
import { PRAISEANDLIKE } from "./emit.js"
import { LIKETYPE } from "@/emit/index.js"
export default {
components: {
PublicSwitching: public_switching,
PraiseItem: praise_item
},
data() {
return {
LIKETYPE,
option: [
{
lable: '全部表扬',
value: PRAISEANDLIKE.WHOLE
},
{
lable: '待审核表扬',
value: PRAISEANDLIKE.PENDINGREVIEW
}
],
current: PRAISEANDLIKE.WHOLE,
total: 0,
dataList: [],
page: 1
}
},
onLoad() {
this.getData()
},
methods: {
success(e) {
this.dataList = this.dataList.filter(item => item.id !== e)
},
changeSwitching(e) {
this.current = e
this.page = 1
this.total = 0
this.dataList = []
this.getData()
},
getData() {
var datas = {
is_uncheck: this.current,
page: this.page,
limit: 10
}
var jkurl = '/admin/praise'
this.$service.P_post(jkurl, datas).then(res => {
this.total = res.data.total
if(this.dataList.length < this.total) {
if(this.page === 1) {
this.dataList = res.data.data
console.log('res====>', res)
} else {
this.dataList.push(...result)
}
this.page++
}
if(this.current === PRAISEANDLIKE.PENDINGREVIEW) {
this.dataList = this.dataList.map(item => {
return {
...item,
showOperation: true
}
})
}
console.log('dataList====>', this.dataList)
})
}
}
}
</script>
<style lang="scss" scoped>
.admin_praise{
.tel_index_bg{
position: absolute;
top: 0;
z-index: 1;
width: 100%;
min-height: 220rpx;
background: linear-gradient(0deg, #f8f8f8 0%, #ffffff 25%, #5D9DFD 60%, #428EFE 70%, #2D81FF 100%);
}
.admin_praise-main{
position: relative;
z-index: 1;
padding: 0rpx 25rpx;
.praise_andLike-list{
margin-top: 30rpx;
height: calc(100vh - 152rpx);
}
}
}
</style>
... ...
/**
* 表扬点赞类型
*/
export const PRAISEANDLIKE = {
/**
* 全部表扬
* @value 0
*/
"WHOLE" : '0',
/**
* 待审核
* @value 1
*/
'PENDINGREVIEW': '1'
}
... ...