Commit 002aea34ae9c7182d0a8cdcab1ffd2063d7b1077

Authored by YunaiV
1 parent 2da6a746

引入 uview 组件

yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/vo/MbrUserInfoRespVO.java
@@ -13,7 +13,7 @@ import lombok.NoArgsConstructor; @@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
13 public class MbrUserInfoRespVO { 13 public class MbrUserInfoRespVO {
14 14
15 @ApiModelProperty(value = "用户昵称", required = true, example = "芋艿") 15 @ApiModelProperty(value = "用户昵称", required = true, example = "芋艿")
16 - private String nickName; 16 + private String nickname;
17 17
18 @ApiModelProperty(value = "用户头像", required = true, example = "/infra/file/get/35a12e57-4297-4faa-bf7d-7ed2f211c952") 18 @ApiModelProperty(value = "用户头像", required = true, example = "/infra/file/get/35a12e57-4297-4faa-bf7d-7ed2f211c952")
19 private String avatar; 19 private String avatar;
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/convert/user/UserProfileConvert.java 0 → 100644
  1 +package cn.iocoder.yudao.userserver.modules.member.convert.user;
  2 +
  3 +import cn.iocoder.yudao.coreservice.modules.member.dal.dataobject.user.MbrUserDO;
  4 +import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.MbrUserInfoRespVO;
  5 +import org.mapstruct.Mapper;
  6 +import org.mapstruct.factory.Mappers;
  7 +
  8 +@Mapper
  9 +public interface UserProfileConvert {
  10 +
  11 + UserProfileConvert INSTANCE = Mappers.getMapper(UserProfileConvert.class);
  12 +
  13 + MbrUserInfoRespVO convert(MbrUserDO bean);
  14 +
  15 +}
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/impl/MbrUserServiceImpl.java
@@ -7,6 +7,7 @@ import cn.iocoder.yudao.coreservice.modules.member.dal.dataobject.user.MbrUserDO @@ -7,6 +7,7 @@ import cn.iocoder.yudao.coreservice.modules.member.dal.dataobject.user.MbrUserDO
7 import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.MbrUserInfoRespVO; 7 import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.MbrUserInfoRespVO;
8 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; 8 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
9 import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.MbrUserUpdateMobileReqVO; 9 import cn.iocoder.yudao.userserver.modules.member.controller.user.vo.MbrUserUpdateMobileReqVO;
  10 +import cn.iocoder.yudao.userserver.modules.member.convert.user.UserProfileConvert;
10 import cn.iocoder.yudao.userserver.modules.member.dal.mysql.user.MbrUserMapper; 11 import cn.iocoder.yudao.userserver.modules.member.dal.mysql.user.MbrUserMapper;
11 import cn.iocoder.yudao.userserver.modules.member.service.user.MbrUserService; 12 import cn.iocoder.yudao.userserver.modules.member.service.user.MbrUserService;
12 import cn.iocoder.yudao.userserver.modules.system.service.auth.SysAuthService; 13 import cn.iocoder.yudao.userserver.modules.system.service.auth.SysAuthService;
@@ -115,10 +116,7 @@ public class MbrUserServiceImpl implements MbrUserService { @@ -115,10 +116,7 @@ public class MbrUserServiceImpl implements MbrUserService {
115 public MbrUserInfoRespVO getUserInfo(Long userId) { 116 public MbrUserInfoRespVO getUserInfo(Long userId) {
116 MbrUserDO user = this.checkUserExists(userId); 117 MbrUserDO user = this.checkUserExists(userId);
117 // 拼接返回结果 118 // 拼接返回结果
118 - MbrUserInfoRespVO userResp = new MbrUserInfoRespVO();  
119 - userResp.setNickName(user.getNickname());  
120 - userResp.setAvatar(user.getAvatar());  
121 - return userResp; 119 + return UserProfileConvert.INSTANCE.convert(user);
122 } 120 }
123 121
124 @Override 122 @Override
yudao-vue-ui/App.vue
@@ -75,6 +75,7 @@ @@ -75,6 +75,7 @@
75 /*每个页面公共css */ 75 /*每个页面公共css */
76 @import url("./common/css/common.css"); 76 @import url("./common/css/common.css");
77 @import url("./common/css/icon.css"); 77 @import url("./common/css/icon.css");
  78 + @import "@/uni_modules/uview-ui/index.scss";
78 79
79 .lazyload{ 80 .lazyload{
80 position: relative; 81 position: relative;
yudao-vue-ui/common/js/request.js
1 -const BASE_URL = 'http://127.0.0.1:28080/api/'; 1 +import store from '@/store'
2 import { msg, getAuthToken } from './util' 2 import { msg, getAuthToken } from './util'
3 3
  4 +const BASE_URL = 'http://127.0.0.1:28080/api/';
  5 +
4 export const request = (options) => { 6 export const request = (options) => {
5 return new Promise((resolve, reject) => { 7 return new Promise((resolve, reject) => {
6 // 发起请求 8 // 发起请求
yudao-vue-ui/common/js/util.js
@@ -61,7 +61,7 @@ export const msg = (title = '', param={}) => { @@ -61,7 +61,7 @@ export const msg = (title = '', param={}) => {
61 * @return {Boolean} 是否登陆 61 * @return {Boolean} 是否登陆
62 */ 62 */
63 export const isLogin = (options = {}) => { 63 export const isLogin = (options = {}) => {
64 - const token = this.getAuthToken(); 64 + const token = getAuthToken();
65 if (token) { 65 if (token) {
66 return true; 66 return true;
67 } 67 }
yudao-vue-ui/main.js
1 import App from './App' 1 import App from './App'
2 2
  3 +import uView from '@/uni_modules/uview-ui'
  4 +Vue.use(uView)
  5 +
3 // 全局 Mixin 6 // 全局 Mixin
4 import mixin from './common/mixin/mixin' 7 import mixin from './common/mixin/mixin'
5 Vue.mixin(mixin) 8 Vue.mixin(mixin)
yudao-vue-ui/pages.json
1 { 1 {
  2 + "easycom": {
  3 + "^u-(.*)": "@/uni_modules/uview-ui/components/u-$1/u-$1.vue"
  4 + },
2 "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages 5 "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
3 { 6 {
4 "path": "pages/index/index", 7 "path": "pages/index/index",
yudao-vue-ui/pages/set/cutImage/cut.js 0 → 100644
  1 +(function(global, factory) {
  2 + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  3 + typeof define === 'function' && define.amd ? define(factory) :
  4 + (global.weCropper = factory());
  5 +}(this, (function() {
  6 + 'use strict';
  7 + var device = void 0;
  8 + var TOUCH_STATE = ['touchstarted', 'touchmoved', 'touchended'];
  9 +
  10 + function firstLetterUpper(str) {
  11 + return str.charAt(0).toUpperCase() + str.slice(1);
  12 + }
  13 +
  14 + function setTouchState(instance) {
  15 + for (var _len = arguments.length, arg = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  16 + arg[_key - 1] = arguments[_key];
  17 + }
  18 +
  19 + TOUCH_STATE.forEach(function(key, i) {
  20 + if (arg[i] !== undefined) {
  21 + instance[key] = arg[i];
  22 + }
  23 + });
  24 + }
  25 +
  26 + function validator(instance, o) {
  27 + Object.defineProperties(instance, o);
  28 + }
  29 +
  30 + function getDevice() {
  31 + if (!device) {
  32 + device = wx.getSystemInfoSync();
  33 + }
  34 + return device;
  35 + }
  36 +
  37 + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
  38 + return typeof obj;
  39 + } : function(obj) {
  40 + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" :
  41 + typeof obj;
  42 + };
  43 +
  44 +
  45 +
  46 +
  47 + var classCallCheck = function(instance, Constructor) {
  48 + if (!(instance instanceof Constructor)) {
  49 + throw new TypeError("Cannot call a class as a function");
  50 + }
  51 + };
  52 +
  53 + var createClass = function() {
  54 + function defineProperties(target, props) {
  55 + for (var i = 0; i < props.length; i++) {
  56 + var descriptor = props[i];
  57 + descriptor.enumerable = descriptor.enumerable || false;
  58 + descriptor.configurable = true;
  59 + if ("value" in descriptor) descriptor.writable = true;
  60 + Object.defineProperty(target, descriptor.key, descriptor);
  61 + }
  62 + }
  63 +
  64 + return function(Constructor, protoProps, staticProps) {
  65 + if (protoProps) defineProperties(Constructor.prototype, protoProps);
  66 + if (staticProps) defineProperties(Constructor, staticProps);
  67 + return Constructor;
  68 + };
  69 + }();
  70 +
  71 +
  72 +
  73 +
  74 + var slicedToArray = function() {
  75 + function sliceIterator(arr, i) {
  76 + var _arr = [];
  77 + var _n = true;
  78 + var _d = false;
  79 + var _e = undefined;
  80 +
  81 + try {
  82 + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  83 + _arr.push(_s.value);
  84 +
  85 + if (i && _arr.length === i) break;
  86 + }
  87 + } catch (err) {
  88 + _d = true;
  89 + _e = err;
  90 + } finally {
  91 + try {
  92 + if (!_n && _i["return"]) _i["return"]();
  93 + } finally {
  94 + if (_d) throw _e;
  95 + }
  96 + }
  97 +
  98 + return _arr;
  99 + }
  100 +
  101 + return function(arr, i) {
  102 + if (Array.isArray(arr)) {
  103 + return arr;
  104 + } else if (Symbol.iterator in Object(arr)) {
  105 + return sliceIterator(arr, i);
  106 + } else {
  107 + throw new TypeError("Invalid attempt to destructure non-iterable instance");
  108 + }
  109 + };
  110 + }();
  111 +
  112 + var tmp = {};
  113 +
  114 + var DEFAULT = {
  115 + id: {
  116 + default: 'cropper',
  117 + get: function get$$1() {
  118 + return tmp.id;
  119 + },
  120 + set: function set$$1(value) {
  121 + if (typeof value !== 'string') {}
  122 + tmp.id = value;
  123 + }
  124 + },
  125 + width: {
  126 + default: 750,
  127 + get: function get$$1() {
  128 + return tmp.width;
  129 + },
  130 + set: function set$$1(value) {
  131 + tmp.width = value;
  132 + }
  133 + },
  134 + height: {
  135 + default: 750,
  136 + get: function get$$1() {
  137 + return tmp.height;
  138 + },
  139 + set: function set$$1(value) {
  140 + tmp.height = value;
  141 + }
  142 + },
  143 + scale: {
  144 + default: 2.5,
  145 + get: function get$$1() {
  146 + return tmp.scale;
  147 + },
  148 + set: function set$$1(value) {
  149 + tmp.scale = value;
  150 + }
  151 + },
  152 + zoom: {
  153 + default: 5,
  154 + get: function get$$1() {
  155 + return tmp.zoom;
  156 + },
  157 + set: function set$$1(value) {
  158 + tmp.zoom = value;
  159 + }
  160 + },
  161 + src: {
  162 + default: 'cropper',
  163 + get: function get$$1() {
  164 + return tmp.src;
  165 + },
  166 + set: function set$$1(value) {
  167 + tmp.src = value;
  168 + }
  169 + },
  170 + cut: {
  171 + default: {},
  172 + get: function get$$1() {
  173 + return tmp.cut;
  174 + },
  175 + set: function set$$1(value) {
  176 + tmp.cut = value;
  177 + }
  178 + },
  179 + onReady: {
  180 + default: null,
  181 + get: function get$$1() {
  182 + return tmp.ready;
  183 + },
  184 + set: function set$$1(value) {
  185 + tmp.ready = value;
  186 + }
  187 + },
  188 + onBeforeImageLoad: {
  189 + default: null,
  190 + get: function get$$1() {
  191 + return tmp.beforeImageLoad;
  192 + },
  193 + set: function set$$1(value) {
  194 + tmp.beforeImageLoad = value;
  195 + }
  196 + },
  197 + onImageLoad: {
  198 + default: null,
  199 + get: function get$$1() {
  200 + return tmp.imageLoad;
  201 + },
  202 + set: function set$$1(value) {
  203 + tmp.imageLoad = value;
  204 + }
  205 + },
  206 + onBeforeDraw: {
  207 + default: null,
  208 + get: function get$$1() {
  209 + return tmp.beforeDraw;
  210 + },
  211 + set: function set$$1(value) {
  212 + tmp.beforeDraw = value;
  213 + }
  214 + }
  215 + };
  216 + function prepare() {
  217 + var self = this;
  218 +
  219 + var _getDevice = getDevice(),
  220 + windowWidth = _getDevice.windowWidth;
  221 +
  222 + self.attachPage = function() {
  223 + var pages = getCurrentPages();
  224 + var pageContext = pages[pages.length - 1];
  225 + pageContext.wecropper = self;
  226 + };
  227 +
  228 + self.createCtx = function() {
  229 + var id = self.id;
  230 +
  231 + if (id) {
  232 + self.ctx = wx.createCanvasContext(id);
  233 + }
  234 + };
  235 +
  236 + self.deviceRadio = windowWidth / 750;
  237 + self.deviceRadio = self.deviceRadio.toFixed(2)
  238 + }
  239 + function observer() {
  240 + var self = this;
  241 +
  242 + var EVENT_TYPE = ['ready', 'beforeImageLoad', 'beforeDraw', 'imageLoad'];
  243 +
  244 + self.on = function(event, fn) {
  245 + if (EVENT_TYPE.indexOf(event) > -1) {
  246 + if (typeof fn === 'function') {
  247 + event === 'ready' ? fn(self) : self['on' + firstLetterUpper(event)] = fn;
  248 + }
  249 + }
  250 + return self;
  251 + };
  252 + }
  253 + function methods() {
  254 + var self = this;
  255 +
  256 + var deviceRadio = self.deviceRadio;
  257 +
  258 + var boundWidth = self.width;
  259 + var boundHeight = self.height;
  260 + var _self$cut = self.cut,
  261 + _self$cut$x = _self$cut.x,
  262 + x = _self$cut$x === undefined ? 0 : _self$cut$x,
  263 + _self$cut$y = _self$cut.y,
  264 + y = _self$cut$y === undefined ? 0 : _self$cut$y,
  265 + _self$cut$width = _self$cut.width,
  266 + width = _self$cut$width === undefined ? boundWidth : _self$cut$width,
  267 + _self$cut$height = _self$cut.height,
  268 + height = _self$cut$height === undefined ? boundHeight : _self$cut$height;
  269 +
  270 +
  271 + self.updateCanvas = function() {
  272 + if (self.croperTarget) {
  273 +
  274 +
  275 + self.ctx.drawImage(self.croperTarget, self.imgLeft, self.imgTop, self.scaleWidth, self.scaleHeight);
  276 + }
  277 + typeof self.onBeforeDraw === 'function' && self.onBeforeDraw(self.ctx, self);
  278 +
  279 + self.setBoundStyle();
  280 + self.ctx.draw();
  281 + return self;
  282 + };
  283 +
  284 + self.pushOrign = function(src) {
  285 + self.src = src;
  286 +
  287 + typeof self.onBeforeImageLoad === 'function' && self.onBeforeImageLoad(self.ctx, self);
  288 +
  289 + uni.getImageInfo({
  290 + src: src,
  291 + success: function success(res) {
  292 + var innerAspectRadio = res.width / res.height;
  293 + self.croperTarget = res.path || src;
  294 + if (innerAspectRadio < width / height) {
  295 + self.rectX = x;
  296 + self.baseWidth = width;
  297 + self.baseHeight = width / innerAspectRadio;
  298 + self.rectY = y - Math.abs((height - self.baseHeight) / 2);
  299 + } else {
  300 + self.rectY = y;
  301 + self.baseWidth = height * innerAspectRadio;
  302 + self.baseHeight = height;
  303 + self.rectX = x - Math.abs((width - self.baseWidth) / 2);
  304 + }
  305 +
  306 + self.imgLeft = self.rectX;
  307 + self.imgTop = self.rectY;
  308 + self.scaleWidth = self.baseWidth;
  309 + self.scaleHeight = self.baseHeight;
  310 +
  311 + self.updateCanvas();
  312 +
  313 + typeof self.onImageLoad === 'function' && self.onImageLoad(self.ctx, self);
  314 + }
  315 + });
  316 +
  317 + self.update();
  318 + return self;
  319 + };
  320 +
  321 + self.getCropperImage = function() {
  322 + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  323 + args[_key] = arguments[_key];
  324 + }
  325 +
  326 + var id = self.id;
  327 +
  328 + var ARG_TYPE = toString.call(args[0]);
  329 + switch (ARG_TYPE) {
  330 + case '[object Object]':
  331 + var _args$0$quality = args[0].quality,
  332 + quality = _args$0$quality === undefined ? 10 : _args$0$quality;
  333 +
  334 + uni.canvasToTempFilePath({
  335 + canvasId: id,
  336 + x: x,
  337 + y: y,
  338 + fileType: "jpg",
  339 + width: width,
  340 + height: height,
  341 + destWidth: width * quality / (deviceRadio * 10),
  342 + destHeight: height * quality / (deviceRadio * 10),
  343 + success: function success(res) {
  344 + typeof args[args.length - 1] === 'function' && args[args.length - 1](res.tempFilePath);
  345 + }
  346 + });
  347 + break;
  348 + case '[object Function]':
  349 + uni.canvasToTempFilePath({
  350 + canvasId: id,
  351 + x: x,
  352 + y: y,
  353 + fileType: "jpg",
  354 + width: width,
  355 + height: height,
  356 + destWidth: width,
  357 + destHeight: height,
  358 + success: function success(res) {
  359 +
  360 + typeof args[args.length - 1] === 'function' && args[args.length - 1](res.tempFilePath);
  361 + }
  362 + });
  363 + break;
  364 + }
  365 +
  366 + return self;
  367 + };
  368 + }
  369 +
  370 + function update() {
  371 + var self = this;
  372 + if (!self.src) return;
  373 +
  374 + self.__oneTouchStart = function(touch) {
  375 + self.touchX0 = touch.x;
  376 + self.touchY0 = touch.y;
  377 + };
  378 +
  379 + self.__oneTouchMove = function(touch) {
  380 + var xMove = void 0,
  381 + yMove = void 0;
  382 + if (self.touchended) {
  383 + return self.updateCanvas();
  384 + }
  385 + xMove = touch.x - self.touchX0;
  386 + yMove = touch.y - self.touchY0;
  387 +
  388 + var imgLeft = self.rectX + xMove;
  389 + var imgTop = self.rectY + yMove;
  390 +
  391 + self.outsideBound(imgLeft, imgTop);
  392 +
  393 + self.updateCanvas();
  394 + };
  395 +
  396 + self.__twoTouchStart = function(touch0, touch1) {
  397 + var xMove = void 0,
  398 + yMove = void 0,
  399 + oldDistance = void 0;
  400 +
  401 + self.touchX1 = self.rectX + self.scaleWidth / 2;
  402 + self.touchY1 = self.rectY + self.scaleHeight / 2;
  403 +
  404 + xMove = touch1.x - touch0.x;
  405 + yMove = touch1.y - touch0.y;
  406 + oldDistance = Math.sqrt(xMove * xMove + yMove * yMove);
  407 +
  408 + self.oldDistance = oldDistance;
  409 + };
  410 +
  411 + self.__twoTouchMove = function(touch0, touch1) {
  412 + var xMove = void 0,
  413 + yMove = void 0,
  414 + newDistance = void 0;
  415 + var scale = self.scale,
  416 + zoom = self.zoom;
  417 +
  418 + xMove = touch1.x - touch0.x;
  419 + yMove = touch1.y - touch0.y;
  420 + newDistance = Math.sqrt(xMove * xMove + yMove * yMove
  421 +
  422 + // 使用0.005的缩放倍数具有良好的缩放体验
  423 + );
  424 + self.newScale = self.oldScale + 0.001 * zoom * (newDistance - self.oldDistance);
  425 +
  426 + // 设定缩放范围
  427 + self.newScale <= 1 && (self.newScale = 1);
  428 + self.newScale >= scale && (self.newScale = scale);
  429 +
  430 + self.scaleWidth = self.newScale * self.baseWidth;
  431 + self.scaleHeight = self.newScale * self.baseHeight;
  432 + var imgLeft = self.touchX1 - self.scaleWidth / 2;
  433 + var imgTop = self.touchY1 - self.scaleHeight / 2;
  434 +
  435 + self.outsideBound(imgLeft, imgTop);
  436 +
  437 + self.updateCanvas();
  438 + };
  439 +
  440 + self.__xtouchEnd = function() {
  441 + self.oldScale = self.newScale;
  442 + self.rectX = self.imgLeft;
  443 + self.rectY = self.imgTop;
  444 + };
  445 + }
  446 + var handle = {
  447 + touchStart: function touchStart(e) {
  448 + var self = this;
  449 + var _e$touches = slicedToArray(e.touches, 2),
  450 + touch0 = _e$touches[0],
  451 + touch1 = _e$touches[1];
  452 +
  453 + if (!touch0.x) {
  454 + touch0.x = touch0.clientX;
  455 + touch0.y = touch0.clientY;
  456 + if (touch1) {
  457 + touch1.x = touch1.clientX;
  458 + touch1.y = touch1.clientY;
  459 + }
  460 + }
  461 +
  462 + setTouchState(self, true, null, null);
  463 + self.__oneTouchStart(touch0);
  464 + if (e.touches.length >= 2) {
  465 + self.__twoTouchStart(touch0, touch1);
  466 + }
  467 + },
  468 +
  469 +
  470 + touchMove: function touchMove(e) {
  471 + var self = this;
  472 +
  473 + var _e$touches2 = slicedToArray(e.touches, 2),
  474 + touch0 = _e$touches2[0],
  475 + touch1 = _e$touches2[1];
  476 + if (!touch0.x) {
  477 + touch0.x = touch0.clientX;
  478 + touch0.y = touch0.clientY;
  479 + if (touch1) {
  480 + touch1.x = touch1.clientX;
  481 + touch1.y = touch1.clientY;
  482 + }
  483 + }
  484 + setTouchState(self, null, true);
  485 + if (e.touches.length === 1) {
  486 + self.__oneTouchMove(touch0);
  487 + }
  488 + if (e.touches.length >= 2) {
  489 + self.__twoTouchMove(touch0, touch1);
  490 + }
  491 + },
  492 + touchEnd: function touchEnd(e) {
  493 + var self = this;
  494 +
  495 + setTouchState(self, false, false, true);
  496 + self.__xtouchEnd();
  497 + }
  498 + };
  499 + function cut() {
  500 + var self = this;
  501 + var deviceRadio = self.deviceRadio;
  502 +
  503 + var boundWidth = self.width;
  504 + var boundHeight = self.height;
  505 + var _self$cut = self.cut,
  506 + _self$cut$x = _self$cut.x,
  507 + x = _self$cut$x === undefined ? 0 : _self$cut$x,
  508 + _self$cut$y = _self$cut.y,
  509 + y = _self$cut$y === undefined ? 0 : _self$cut$y,
  510 + _self$cut$width = _self$cut.width,
  511 + width = _self$cut$width === undefined ? boundWidth : _self$cut$width,
  512 + _self$cut$height = _self$cut.height,
  513 + height = _self$cut$height === undefined ? boundHeight : _self$cut$height;
  514 +
  515 +
  516 + self.outsideBound = function(imgLeft, imgTop) {
  517 + self.imgLeft = imgLeft >= x ? x : self.scaleWidth + imgLeft - x <= width ? x + width - self.scaleWidth : imgLeft;
  518 +
  519 + self.imgTop = imgTop >= y ? y : self.scaleHeight + imgTop - y <= height ? y + height - self.scaleHeight : imgTop;
  520 + };
  521 +
  522 + self.setBoundStyle = function() {
  523 + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  524 + _ref$color = _ref.color,
  525 + color = _ref$color === undefined ? '#04b00f' : _ref$color,
  526 + _ref$mask = _ref.mask,
  527 + mask = _ref$mask === undefined ? 'rgba(0, 0, 0, 0.5)' : _ref$mask,
  528 + _ref$lineWidth = _ref.lineWidth,
  529 + lineWidth = _ref$lineWidth === undefined ? 1 : _ref$lineWidth;
  530 +
  531 + self.ctx.beginPath();
  532 + self.ctx.setFillStyle(mask);
  533 + self.ctx.fillRect(0, 0, x, boundHeight);
  534 + self.ctx.fillRect(x, 0, width, y);
  535 + self.ctx.fillRect(x, y + height, width, boundHeight - y - height);
  536 + self.ctx.fillRect(x + width, 0, boundWidth - x - width, boundHeight);
  537 + self.ctx.fill();
  538 + self.ctx.beginPath();
  539 + self.ctx.setStrokeStyle(color);
  540 + self.ctx.setLineWidth(lineWidth);
  541 + self.ctx.moveTo(x - lineWidth, y + 10 - lineWidth);
  542 + self.ctx.lineTo(x - lineWidth, y - lineWidth);
  543 + self.ctx.lineTo(x + 10 - lineWidth, y - lineWidth);
  544 + self.ctx.stroke();
  545 + self.ctx.beginPath();
  546 + self.ctx.setStrokeStyle(color);
  547 + self.ctx.setLineWidth(lineWidth);
  548 + self.ctx.moveTo(x - lineWidth, y + height - 10 + lineWidth);
  549 + self.ctx.lineTo(x - lineWidth, y + height + lineWidth);
  550 + self.ctx.lineTo(x + 10 - lineWidth, y + height + lineWidth);
  551 + self.ctx.stroke();
  552 + self.ctx.beginPath();
  553 + self.ctx.setStrokeStyle(color);
  554 + self.ctx.setLineWidth(lineWidth);
  555 + self.ctx.moveTo(x + width - 10 + lineWidth, y - lineWidth);
  556 + self.ctx.lineTo(x + width + lineWidth, y - lineWidth);
  557 + self.ctx.lineTo(x + width + lineWidth, y + 10 - lineWidth);
  558 + self.ctx.stroke();
  559 + self.ctx.beginPath();
  560 + self.ctx.setStrokeStyle(color);
  561 + self.ctx.setLineWidth(lineWidth);
  562 + self.ctx.moveTo(x + width + lineWidth, y + height - 10 + lineWidth);
  563 + self.ctx.lineTo(x + width + lineWidth, y + height + lineWidth);
  564 + self.ctx.lineTo(x + width - 10 + lineWidth, y + height + lineWidth);
  565 + self.ctx.stroke();
  566 + };
  567 + }
  568 +
  569 + var __version__ = '1.1.4';
  570 +
  571 + var weCropper = function() {
  572 + function weCropper(params) {
  573 + classCallCheck(this, weCropper);
  574 +
  575 + var self = this;
  576 + var _default = {};
  577 +
  578 + validator(self, DEFAULT);
  579 +
  580 + Object.keys(DEFAULT).forEach(function(key) {
  581 + _default[key] = DEFAULT[key].default;
  582 + });
  583 + Object.assign(self, _default, params);
  584 +
  585 + self.prepare();
  586 + self.attachPage();
  587 + self.createCtx();
  588 + self.observer();
  589 + self.cutt();
  590 + self.methods();
  591 + self.init();
  592 + self.update();
  593 +
  594 + return self;
  595 + }
  596 +
  597 + createClass(weCropper, [{
  598 + key: 'init',
  599 + value: function init() {
  600 + var self = this;
  601 + var src = self.src;
  602 +
  603 +
  604 + self.version = __version__;
  605 +
  606 + typeof self.onReady === 'function' && self.onReady(self.ctx, self);
  607 +
  608 + if (src) {
  609 + self.pushOrign(src);
  610 + }
  611 + setTouchState(self, false, false, false);
  612 +
  613 + self.oldScale = 1;
  614 + self.newScale = 1;
  615 +
  616 + return self;
  617 + }
  618 + }]);
  619 + return weCropper;
  620 + }();
  621 +
  622 + Object.assign(weCropper.prototype, handle);
  623 +
  624 +
  625 + weCropper.prototype.prepare = prepare;
  626 + weCropper.prototype.observer = observer;
  627 + weCropper.prototype.methods = methods;
  628 + weCropper.prototype.cutt = cut;
  629 + weCropper.prototype.update = update;
  630 +
  631 + return weCropper;
  632 +
  633 +})));
yudao-vue-ui/pages/set/cutImage/cut.vue 0 → 100644
  1 +<template>
  2 + <view class="content">
  3 + <view class="title-view" :style="{height: navigationBarHeight + 'px'}">
  4 + <navigator open-type="navigateBack" class="back-btn mix-icon icon-xiangzuo"></navigator>
  5 + <text class="title">裁剪</text>
  6 + <text class="empty"></text>
  7 + </view>
  8 +
  9 + <view class="cropper-wrapper">
  10 + <canvas
  11 + class="cropper"
  12 + disable-scroll="true"
  13 + @touchstart="touchStart"
  14 + @touchmove="touchMove"
  15 + @touchend="touchEnd"
  16 + :style="{ width: cropperOpt.width, height: cropperOpt.height }"
  17 + canvas-id="cropper"
  18 + ></canvas>
  19 + </view>
  20 + <view class="cropper-buttons">
  21 + <view class="btn upload" @tap="uploadTap">重选</view>
  22 + <view class="btn getCropperImage" @tap="getCropperImage">确定</view>
  23 + </view>
  24 + </view>
  25 +</template>
  26 +
  27 +<script>
  28 + import weCropper from './cut.js';
  29 + const device = uni.getSystemInfoSync();
  30 + const width = device.windowWidth;
  31 + const height = device.windowHeight;
  32 +
  33 + export default {
  34 + data() {
  35 + return {
  36 + cropperOpt: {
  37 + id: 'cropper',
  38 + width: width,
  39 + height: height,
  40 + scale: 2.5,
  41 + zoom: 8,
  42 + cut: {
  43 + x: (width - 200) / 2,
  44 + y: (height - this.systemInfo.navigationBarHeight - this.systemInfo.statusBarHeight - 200) / 2,
  45 + width: 200,
  46 + height: 200
  47 + }
  48 + },
  49 + weCropper: ''
  50 + };
  51 + },
  52 + computed: {
  53 + navigationBarHeight(){
  54 + console.log(this.systemInfo.navigationBarHeight);
  55 + return this.systemInfo.navigationBarHeight;
  56 + }
  57 + },
  58 + onLoad(option) {
  59 + // do something
  60 + const cropperOpt = this.cropperOpt;
  61 + const src = option.src;
  62 + console.log(src);
  63 + if (src) {
  64 + Object.assign(cropperOpt, {
  65 + src
  66 + });
  67 +
  68 + this.weCropper = new weCropper(cropperOpt)
  69 + .on('ready', function(ctx) {})
  70 + .on('beforeImageLoad', ctx => {
  71 + /* uni.showToast({
  72 + title: '上传中',
  73 + icon: 'loading',
  74 + duration: 3000
  75 + }); */
  76 + })
  77 + .on('imageLoad', ctx => {
  78 + uni.hideToast();
  79 + });
  80 + }
  81 + },
  82 + methods: {
  83 + touchStart(e) {
  84 + this.weCropper.touchStart(e);
  85 + },
  86 + touchMove(e) {
  87 + this.weCropper.touchMove(e);
  88 + },
  89 + touchEnd(e) {
  90 + this.weCropper.touchEnd(e);
  91 + },
  92 + convertBase64UrlToBlob(dataURI, type) {
  93 + var binary = atob(dataURI.split(',')[1]);
  94 + var array = [];
  95 + for (var i = 0; i < binary.length; i++) {
  96 + array.push(binary.charCodeAt(i));
  97 + }
  98 + return new Blob([new Uint8Array(array)], {
  99 + type: type
  100 + }, {
  101 + filename: '1111.jpg'
  102 + });
  103 + },
  104 + blobToDataURL(blob) {
  105 + var a = new FileReader();
  106 + a.readAsDataURL(blob); //读取文件保存在result中
  107 + a.onload = function(e) {
  108 + var getRes = e.target.result; //读取的结果在result中
  109 + console.log(getRes);
  110 + };
  111 + },
  112 + getCropperImage() {
  113 + let _this = this;
  114 + this.weCropper.getCropperImage(avatar => {
  115 + if (avatar) {
  116 + this.$util.prePage().setAvatar(avatar);
  117 + uni.navigateBack();
  118 +
  119 + } else {
  120 + console.log('获取图片失败,请稍后重试');
  121 + }
  122 + });
  123 + },
  124 + uploadTap() {
  125 + const self = this;
  126 +
  127 + uni.chooseImage({
  128 + count: 1, // 默认9
  129 + sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
  130 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
  131 + success(res) {
  132 + let src = res.tempFilePaths[0];
  133 + // 获取裁剪图片资源后,给data添加src属性及其值
  134 + self.weCropper.pushOrign(src);
  135 + }
  136 + });
  137 + }
  138 + },
  139 + };
  140 +</script>
  141 +
  142 +<style lang="scss">
  143 + page, .content{
  144 + width: 100%;
  145 + height: 100%;
  146 + overflow: hidden;
  147 + }
  148 + .content {
  149 + display: flex;
  150 + flex-direction: column;
  151 + background-color: #000;
  152 + padding-top: var(--status-bar-height);
  153 + }
  154 +
  155 + .title-view{
  156 + flex-shrink: 0;
  157 + display: flex;
  158 + align-items: center;
  159 + justify-content: space-between;
  160 + width: 100%;
  161 + background: transparent;
  162 +
  163 + .back-btn{
  164 + display: flex;
  165 + justify-content: center;
  166 + align-items: center;
  167 + width: 42px;
  168 + height: 40px;
  169 + font-size: 18px;
  170 + color: #fff;
  171 + }
  172 + .title{
  173 + font-size: 17px;
  174 + color: #fff;
  175 + }
  176 + .empty{
  177 + width: 42px;
  178 + }
  179 + }
  180 +
  181 + .cropper {
  182 + width: 100%;
  183 + flex: 1;
  184 + }
  185 +
  186 + .cropper-wrapper {
  187 + flex: 1;
  188 + position: relative;
  189 + display: flex;
  190 + flex-direction: column;
  191 + justify-content: space-between;
  192 + align-items: center;
  193 + width: 100%;
  194 + background-color: #000;
  195 + }
  196 +
  197 + .cropper-buttons {
  198 + flex-shrink: 0;
  199 + display: flex;
  200 + justify-content: space-between;
  201 + align-items: center;
  202 + width: 100%;
  203 + height: 50px;
  204 + background-color: rgba(0, 0, 0, 0.4);
  205 +
  206 + .btn{
  207 + width: 100px;
  208 + height: 50px;
  209 + line-height: 50px;
  210 + font-size: 15px;
  211 + color: #fff;
  212 +
  213 + &.upload{
  214 + padding-left: 20px;
  215 + }
  216 +
  217 + &.getCropperImage{
  218 + padding-right: 20px;
  219 + text-align: right;
  220 + }
  221 + }
  222 + }
  223 +</style>
yudao-vue-ui/pages/set/userInfo.vue
@@ -5,8 +5,7 @@ @@ -5,8 +5,7 @@
5 <view class="avatar-wrap" @click="chooseImage"> 5 <view class="avatar-wrap" @click="chooseImage">
6 <image class="avatar" :src="tempAvatar || userInfo.avatar || '/static/icon/default-avatar.png'" mode="aspectFill"></image> 6 <image class="avatar" :src="tempAvatar || userInfo.avatar || '/static/icon/default-avatar.png'" mode="aspectFill"></image>
7 <!-- 进度遮盖 --> 7 <!-- 进度遮盖 -->
8 - <view  
9 - class="progress center" 8 + <view class="progress center"
10 :class="{ 9 :class="{
11 'no-transtion': uploadProgress === 0, 10 'no-transtion': uploadProgress === 0,
12 show: uploadProgress != 100 11 show: uploadProgress != 100
@@ -14,27 +13,13 @@ @@ -14,27 +13,13 @@
14 :style="{ 13 :style="{
15 width: uploadProgress + '%', 14 width: uploadProgress + '%',
16 height: uploadProgress + '%', 15 height: uploadProgress + '%',
17 - }"  
18 - ></view> 16 + }"></view>
19 </view> 17 </view>
20 </view> 18 </view>
21 <view class="cell b-b"> 19 <view class="cell b-b">
22 <text class="tit fill">昵称</text> 20 <text class="tit fill">昵称</text>
23 <input class="input" v-model="userInfo.nickname" type="text" maxlength="8" placeholder="请输入昵称" placeholder-class="placeholder"> 21 <input class="input" v-model="userInfo.nickname" type="text" maxlength="8" placeholder="请输入昵称" placeholder-class="placeholder">
24 </view> 22 </view>
25 - <view class="cell b-b">  
26 - <text class="tit fill">性别</text>  
27 - <view class="checkbox center" @click="changeGender(1)">  
28 - <text v-if="userInfo.gender == 1" class="mix-icon icon-xuanzhong"></text>  
29 - <text v-else class="mix-icon icon-yk_yuanquan"></text>  
30 - <text>男</text>  
31 - </view>  
32 - <view class="checkbox center" @click="changeGender(2)">  
33 - <text v-if="userInfo.gender == 2" class="mix-icon icon-xuanzhong"></text>  
34 - <text v-else class="mix-icon icon-yk_yuanquan"></text>  
35 - <text>女</text>  
36 - </view>  
37 - </view>  
38 23
39 <mix-button ref="confirmBtn" text="保存资料" marginTop="80rpx" @onConfirm="confirm"></mix-button> 24 <mix-button ref="confirmBtn" text="保存资料" marginTop="80rpx" @onConfirm="confirm"></mix-button>
40 </view> 25 </view>
@@ -65,11 +50,12 @@ @@ -65,11 +50,12 @@
65 this.userInfo = {avatar, nickname, gender}; 50 this.userInfo = {avatar, nickname, gender};
66 }, 51 },
67 methods: { 52 methods: {
68 - //提交修改  
69 - async confirm(){ 53 + // 提交修改
  54 + async confirm() {
  55 + // 校验信息是否变化
70 const {uploadProgress, userInfo, curUserInfo} = this; 56 const {uploadProgress, userInfo, curUserInfo} = this;
71 let isUpdate = false; 57 let isUpdate = false;
72 - for(let key in userInfo){ 58 + for (let key in userInfo) {
73 if(userInfo[key] !== curUserInfo[key]){ 59 if(userInfo[key] !== curUserInfo[key]){
74 isUpdate = true; 60 isUpdate = true;
75 break; 61 break;
@@ -95,11 +81,6 @@ @@ -95,11 +81,6 @@
95 this.$refs.confirmBtn.stop(); 81 this.$refs.confirmBtn.stop();
96 return; 82 return;
97 } 83 }
98 - if (!userInfo.gender) {  
99 - this.$util.msg('请选择您的性别');  
100 - this.$refs.confirmBtn.stop();  
101 - return;  
102 - }  
103 const res = await this.$request('user', 'update', userInfo); 84 const res = await this.$request('user', 'update', userInfo);
104 this.$refs.confirmBtn.stop(); 85 this.$refs.confirmBtn.stop();
105 this.$util.msg(res.msg); 86 this.$util.msg(res.msg);
@@ -110,7 +91,7 @@ @@ -110,7 +91,7 @@
110 }, 1000) 91 }, 1000)
111 } 92 }
112 }, 93 },
113 - //选择头像 94 + // 选择头像
114 chooseImage(){ 95 chooseImage(){
115 uni.chooseImage({ 96 uni.chooseImage({
116 count: 1, 97 count: 1,
@@ -121,7 +102,7 @@ @@ -121,7 +102,7 @@
121 } 102 }
122 }); 103 });
123 }, 104 },
124 - //裁剪回调 105 + // 裁剪回调
125 async setAvatar(filePath){ 106 async setAvatar(filePath){
126 this.tempAvatar = filePath; 107 this.tempAvatar = filePath;
127 this.uploadProgress = 0; 108 this.uploadProgress = 0;
@@ -151,10 +132,6 @@ @@ -151,10 +132,6 @@
151 this.$util.msg('头像上传失败'); 132 this.$util.msg('头像上传失败');
152 } 133 }
153 } 134 }
154 - },  
155 - //修改性别  
156 - changeGender(gender){  
157 - this.$set(this.userInfo, 'gender', gender)  
158 } 135 }
159 } 136 }
160 } 137 }
yudao-vue-ui/pages/tabbar/user.vue
@@ -52,27 +52,20 @@ @@ -52,27 +52,20 @@
52 </view> 52 </view>
53 53
54 <!-- 功能入口 --> 54 <!-- 功能入口 -->
55 - <view class="option-wrap">  
56 - <!-- <mix-list-cell icon="icon-iconfontweixin" iconColor="#fa436a" title="我的钱包" @onClick="navTo('/pages/wallet/index', {login: true})"></mix-list-cell> -->  
57 - <!-- <mix-list-cell icon="icon-dizhi" iconColor="#5fcda2" title="地址管理" @onClick="navTo('/pages/address/list', {login: true})"></mix-list-cell> -->  
58 - <!-- <mix-list-cell icon="icon-share" iconColor="#9789f7" title="分享" tips="呼朋唤友赢好礼"></mix-list-cell> -->  
59 - <!-- <mix-list-cell icon="icon-shoucang_xuanzhongzhuangtai" iconColor="#54b4ef" title="我的收藏" @onClick="navTo('/pages/favorite/favorite', {login: true})"></mix-list-cell> -->  
60 - <!-- <mix-list-cell icon="icon-pinglun-copy" iconColor="#ee883b" title="意见反馈" @onClick="navTo('/pages/feedback/feedback', {login: true})"></mix-list-cell> -->  
61 - <!-- <mix-list-cell icon="icon-shezhi1" iconColor="#37b0fb" title="设置" border="" @onClick="navTo('/pages/set/set', {login: true})"></mix-list-cell> -->  
62 - <mix-list-cell icon="icon-bianji" iconColor="#5fcda2" title="个人信息" border="" @onClick="navTo('/pages/set/userInfo', {login: true})"></mix-list-cell>  
63 - <mix-list-cell icon="icon-shezhi1" iconColor="#37b0fb" title="账号安全" border="" @onClick="navTo('/pages/set/set', {login: true})"></mix-list-cell>  
64 - </view> 55 + <u-cell-group class="option1-wrap">
  56 + <u-cell icon="edit-pen" title="个人信息" isLink @click="navTo('/pages/set/userInfo', {login: true})"></u-cell>
  57 + <u-cell icon="setting" title="账号安全" isLink @click="navTo('/pages/set/set', {login: true})"></u-cell>
  58 + </u-cell-group>
65 </view> 59 </view>
66 </template> 60 </template>
67 61
68 <script> 62 <script>
  63 + import { mapState, mapGetters } from 'vuex'
  64 + import { isLogin } from '@/common/js/util.js'
  65 +
69 export default { 66 export default {
70 data() { 67 data() {
71 return { 68 return {
72 - userInfo: { // TODO 芋艿:读取  
73 - nickname: '芋艿'  
74 - },  
75 - hasLogin: true, // TODO 芋艿:读取  
76 orderCount: { // TODO 芋艿:读取 69 orderCount: { // TODO 芋艿:读取
77 c0: 1, 70 c0: 1,
78 c1: 2, 71 c1: 2,
@@ -81,9 +74,15 @@ @@ -81,9 +74,15 @@
81 } 74 }
82 }; 75 };
83 }, 76 },
  77 + computed: {
  78 + ...mapState(['userInfo']),
  79 + ...mapGetters(['hasLogin']),
  80 + },
84 onShow() { 81 onShow() {
85 - // 获得用户信息  
86 - this.$store.dispatch('obtainUserInfo'); 82 + // 获得用户信息 TODO 芋艿:
  83 + // if (isLogin()) {
  84 + // this.$store.dispatch('obtainUserInfo');
  85 + // }
87 // TODO 芋艿:获得订单数量 86 // TODO 芋艿:获得订单数量
88 } 87 }
89 } 88 }
@@ -211,12 +210,4 @@ @@ -211,12 +210,4 @@
211 } 210 }
212 } 211 }
213 } 212 }
214 -  
215 - .option-wrap {  
216 - width: 700rpx;  
217 - margin: 20rpx auto 0;  
218 - margin-top: 20rpx;  
219 - background: #fff;  
220 - border-radius: 10rpx;  
221 - }  
222 </style> 213 </style>
yudao-vue-ui/uni.scss
@@ -37,4 +37,6 @@ $black : #000 ; @@ -37,4 +37,6 @@ $black : #000 ;
37 $gray : #777 ; 37 $gray : #777 ;
38 $grey : #82939c ; 38 $grey : #82939c ;
39 39
40 -$borderColor:#e0e0e0;  
41 \ No newline at end of file 40 \ No newline at end of file
  41 +$borderColor:#e0e0e0;
  42 +
  43 +@import '@/uni_modules/uview-ui/theme.scss';