针对个人主页与照片显示做了修改
This commit is contained in:
Vendored
+184
-64
@@ -1,6 +1,54 @@
|
||||
"use strict";
|
||||
(wx["webpackJsonp"] = wx["webpackJsonp"] || []).push([["common"],{
|
||||
|
||||
/***/ "./src/components/LoginGuard/index.tsx":
|
||||
/*!*********************************************!*\
|
||||
!*** ./src/components/LoginGuard/index.tsx ***!
|
||||
\*********************************************/
|
||||
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": function() { return /* binding */ LoginGuard; }
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/taro */ "./node_modules/@tarojs/taro/index.js");
|
||||
/* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
|
||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/cjs/react-jsx-runtime.production.min.js");
|
||||
|
||||
|
||||
|
||||
function LoginGuard(props) {
|
||||
var user = _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync('smart_user_info');
|
||||
if (!(user !== null && user !== void 0 && user.openid)) {
|
||||
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.View, {
|
||||
className: "login-guard",
|
||||
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.Text, {
|
||||
className: "login-guard-icon",
|
||||
children: "\uD83D\uDD12"
|
||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.Text, {
|
||||
className: "login-guard-title",
|
||||
children: "\u8BF7\u5148\u767B\u5F55"
|
||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.Text, {
|
||||
className: "login-guard-desc",
|
||||
children: "\u767B\u5F55\u540E\u67E5\u770B\u60A8\u7684\u4E13\u5C5E\u5185\u5BB9"
|
||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.View, {
|
||||
className: "btn-gradient login-guard-btn",
|
||||
onClick: function onClick() {
|
||||
return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().switchTab({
|
||||
url: '/pages/profile/index'
|
||||
});
|
||||
},
|
||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.Text, {
|
||||
children: "\u53BB\u767B\u5F55"
|
||||
})
|
||||
})]
|
||||
});
|
||||
}
|
||||
return props.children;
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/components/ThemeToggle/index.tsx":
|
||||
/*!**********************************************!*\
|
||||
!*** ./src/components/ThemeToggle/index.tsx ***!
|
||||
@@ -10,30 +58,31 @@
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": function() { return /* binding */ ThemeToggle; }
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/cjs/react.production.min.js");
|
||||
/* harmony import */ var _context_ThemeContext__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../context/ThemeContext */ "./src/context/ThemeContext.tsx");
|
||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/cjs/react-jsx-runtime.production.min.js");
|
||||
/* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
|
||||
/* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/taro */ "./node_modules/@tarojs/taro/index.js");
|
||||
/* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "./node_modules/react/cjs/react.production.min.js");
|
||||
/* harmony import */ var _context_ThemeContext__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../context/ThemeContext */ "./src/context/ThemeContext.tsx");
|
||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/cjs/react-jsx-runtime.production.min.js");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function ThemeToggle() {
|
||||
var _useThemeContext = (0,_context_ThemeContext__WEBPACK_IMPORTED_MODULE_1__.useThemeContext)(),
|
||||
var _useThemeContext = (0,_context_ThemeContext__WEBPACK_IMPORTED_MODULE_2__.useThemeContext)(),
|
||||
theme = _useThemeContext.theme,
|
||||
toggleTheme = _useThemeContext.toggleTheme;
|
||||
var handleToggle = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
|
||||
var handleToggle = (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(function () {
|
||||
toggleTheme();
|
||||
// 触发全局事件,让其他已挂载页面也能感知
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
var Taro = (__webpack_require__(/*! @tarojs/taro */ "./node_modules/@tarojs/taro/index.js")["default"]);
|
||||
Taro.eventCenter.trigger('theme:storageChanged');
|
||||
// 触发全局事件,让其他页面也能感知(切换tab后回来的页面会重新读取storage)
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().eventCenter.trigger('theme:change');
|
||||
}, [toggleTheme]);
|
||||
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_3__.View, {
|
||||
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_4__.View, {
|
||||
className: "theme-toggle",
|
||||
onClick: handleToggle,
|
||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_3__.Text, {
|
||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_4__.Text, {
|
||||
className: "theme-icon",
|
||||
children: theme === 'light' ? '🌙' : '☀️'
|
||||
})
|
||||
@@ -225,8 +274,12 @@ var getProductById = function getProductById(id) {
|
||||
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ addAddress: function() { return /* binding */ addAddress; },
|
||||
/* harmony export */ addDesign: function() { return /* binding */ addDesign; },
|
||||
/* harmony export */ clearUserInfo: function() { return /* binding */ clearUserInfo; },
|
||||
/* harmony export */ deleteAddress: function() { return /* binding */ deleteAddress; },
|
||||
/* harmony export */ designToOrder: function() { return /* binding */ designToOrder; },
|
||||
/* harmony export */ getAddressList: function() { return /* binding */ getAddressList; },
|
||||
/* harmony export */ getDesignList: function() { return /* binding */ getDesignList; },
|
||||
/* harmony export */ getOrderList: function() { return /* binding */ getOrderList; },
|
||||
/* harmony export */ getTheme: function() { return /* binding */ getTheme; },
|
||||
@@ -234,9 +287,10 @@ var getProductById = function getProductById(id) {
|
||||
/* harmony export */ setDesignList: function() { return /* binding */ setDesignList; },
|
||||
/* harmony export */ setTheme: function() { return /* binding */ setTheme; },
|
||||
/* harmony export */ setUserInfo: function() { return /* binding */ setUserInfo; },
|
||||
/* harmony export */ updateAddress: function() { return /* binding */ updateAddress; },
|
||||
/* harmony export */ updateDesign: function() { return /* binding */ updateDesign; }
|
||||
/* harmony export */ });
|
||||
/* unused harmony export setOrderList */
|
||||
/* unused harmony exports getUserInfoRaw, setUserInfoRaw, setOrderList, setAddressList, getDefaultAddress */
|
||||
/* harmony import */ var F_weixin_wordc_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */ "./node_modules/@babel/runtime/helpers/esm/objectSpread2.js");
|
||||
/* harmony import */ var F_weixin_wordc_node_modules_babel_runtime_helpers_esm_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js */ "./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js");
|
||||
/* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/taro */ "./node_modules/@tarojs/taro/index.js");
|
||||
@@ -244,41 +298,62 @@ var getProductById = function getProductById(id) {
|
||||
|
||||
|
||||
|
||||
var DESIGN_KEY = 'smart_design_list';
|
||||
var ORDER_KEY = 'smart_order_list';
|
||||
var USER_KEY = 'smart_user_info';
|
||||
var THEME_KEY = 'smart_theme';
|
||||
var USER_KEY = 'smart_user_info';
|
||||
var ACTIVE_USER_KEY = 'smart_active_openid';
|
||||
|
||||
/** 获取设计清单 */
|
||||
var getDesignList = function getDesignList() {
|
||||
// ---------- 当前用户 openid 管理 ----------
|
||||
|
||||
function getActiveOpenid() {
|
||||
var user = getUserInfoRaw();
|
||||
var openid = (user === null || user === void 0 ? void 0 : user.openid) || _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync(ACTIVE_USER_KEY) || '_guest_';
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().setStorageSync(ACTIVE_USER_KEY, openid);
|
||||
return openid;
|
||||
}
|
||||
function key(scope) {
|
||||
var prefix = getActiveOpenid();
|
||||
return "".concat(scope, "_").concat(prefix);
|
||||
}
|
||||
|
||||
// ---------- 用户数据 ----------
|
||||
|
||||
function getUserInfoRaw() {
|
||||
try {
|
||||
return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync(DESIGN_KEY) || [];
|
||||
return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync(USER_KEY);
|
||||
} catch (_unused) {
|
||||
return [];
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
function setUserInfoRaw(info) {
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().setStorageSync(USER_KEY, info);
|
||||
if (info !== null && info !== void 0 && info.openid) {
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().setStorageSync(ACTIVE_USER_KEY, info.openid);
|
||||
}
|
||||
}
|
||||
function clearUserInfo() {
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().removeStorageSync(USER_KEY);
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().removeStorageSync(ACTIVE_USER_KEY);
|
||||
}
|
||||
function setUserInfo(info) {
|
||||
setUserInfoRaw(info);
|
||||
}
|
||||
function getUserInfo() {
|
||||
return getUserInfoRaw();
|
||||
}
|
||||
|
||||
/** 保存设计清单 */
|
||||
var setDesignList = function setDesignList(list) {
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().setStorageSync(DESIGN_KEY, list);
|
||||
};
|
||||
// ---------- 设计清单 ----------
|
||||
|
||||
/** 获取订单列表 */
|
||||
var getOrderList = function getOrderList() {
|
||||
function getDesignList() {
|
||||
try {
|
||||
return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync(ORDER_KEY) || [];
|
||||
return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync(key('design_list')) || [];
|
||||
} catch (_unused2) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
/** 保存订单列表 */
|
||||
var setOrderList = function setOrderList(list) {
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().setStorageSync(ORDER_KEY, list);
|
||||
};
|
||||
|
||||
/** 添加设计清单条目 */
|
||||
var addDesign = function addDesign(product, count) {
|
||||
}
|
||||
function setDesignList(list) {
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().setStorageSync(key('design_list'), list);
|
||||
}
|
||||
function addDesign(product, count) {
|
||||
var list = getDesignList();
|
||||
var item = {
|
||||
id: 'DSG' + Date.now(),
|
||||
@@ -292,10 +367,8 @@ var addDesign = function addDesign(product, count) {
|
||||
};
|
||||
setDesignList([].concat((0,F_weixin_wordc_node_modules_babel_runtime_helpers_esm_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_1__["default"])(list), [item]));
|
||||
return item;
|
||||
};
|
||||
|
||||
/** 更新设计清单条目 */
|
||||
var updateDesign = function updateDesign(id, patch) {
|
||||
}
|
||||
function updateDesign(id, patch) {
|
||||
var list = getDesignList();
|
||||
var idx = list.findIndex(function (d) {
|
||||
return d.id === id;
|
||||
@@ -303,10 +376,21 @@ var updateDesign = function updateDesign(id, patch) {
|
||||
if (idx === -1) return;
|
||||
list[idx] = (0,F_weixin_wordc_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_2__["default"])((0,F_weixin_wordc_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_2__["default"])({}, list[idx]), patch);
|
||||
setDesignList(list);
|
||||
};
|
||||
}
|
||||
|
||||
/** 设计转订单 */
|
||||
var designToOrder = function designToOrder(designId) {
|
||||
// ---------- 订单 ----------
|
||||
|
||||
function getOrderList() {
|
||||
try {
|
||||
return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync(key('order_list')) || [];
|
||||
} catch (_unused3) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
function setOrderList(list) {
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().setStorageSync(key('order_list'), list);
|
||||
}
|
||||
function designToOrder(designId) {
|
||||
var dList = getDesignList();
|
||||
var oList = getOrderList();
|
||||
var design = dList.find(function (d) {
|
||||
@@ -328,8 +412,6 @@ var designToOrder = function designToOrder(designId) {
|
||||
count: design.count,
|
||||
sku: "".concat(design.productName, " \xD7 ").concat(design.count)
|
||||
};
|
||||
|
||||
// 更新 design 状态
|
||||
var dIdx = dList.findIndex(function (d) {
|
||||
return d.id === designId;
|
||||
});
|
||||
@@ -340,32 +422,70 @@ var designToOrder = function designToOrder(designId) {
|
||||
setDesignList(dList);
|
||||
setOrderList([order].concat((0,F_weixin_wordc_node_modules_babel_runtime_helpers_esm_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_1__["default"])(oList)));
|
||||
return order;
|
||||
};
|
||||
}
|
||||
|
||||
/** 用户数据 */
|
||||
var getUserInfo = function getUserInfo() {
|
||||
try {
|
||||
return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync(USER_KEY);
|
||||
} catch (_unused3) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
var setUserInfo = function setUserInfo(info) {
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().setStorageSync(USER_KEY, info);
|
||||
};
|
||||
// ---------- 主题 ----------
|
||||
|
||||
/** 主题 */
|
||||
|
||||
var getTheme = function getTheme() {
|
||||
function getTheme() {
|
||||
try {
|
||||
return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync(THEME_KEY) || 'light';
|
||||
} catch (_unused4) {
|
||||
return 'light';
|
||||
}
|
||||
};
|
||||
var setTheme = function setTheme(theme) {
|
||||
}
|
||||
function setTheme(theme) {
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().setStorageSync(THEME_KEY, theme);
|
||||
};
|
||||
}
|
||||
|
||||
// ---------- 收货地址 ----------
|
||||
|
||||
function getAddressList() {
|
||||
try {
|
||||
return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync(key('address_list')) || [];
|
||||
} catch (_unused5) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
function setAddressList(list) {
|
||||
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().setStorageSync(key('address_list'), list);
|
||||
}
|
||||
function addAddress(addr) {
|
||||
var list = getAddressList();
|
||||
var item = (0,F_weixin_wordc_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_2__["default"])((0,F_weixin_wordc_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_2__["default"])({}, addr), {}, {
|
||||
id: 'ADR' + Date.now()
|
||||
});
|
||||
// 若设为默认,取消其他默认
|
||||
if (item.isDefault) {
|
||||
list.forEach(function (a) {
|
||||
a.isDefault = false;
|
||||
});
|
||||
}
|
||||
setAddressList([item].concat((0,F_weixin_wordc_node_modules_babel_runtime_helpers_esm_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_1__["default"])(list)));
|
||||
return item;
|
||||
}
|
||||
function updateAddress(id, patch) {
|
||||
var list = getAddressList();
|
||||
var idx = list.findIndex(function (a) {
|
||||
return a.id === id;
|
||||
});
|
||||
if (idx === -1) return;
|
||||
if (patch.isDefault) list.forEach(function (a) {
|
||||
a.isDefault = false;
|
||||
});
|
||||
list[idx] = (0,F_weixin_wordc_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_2__["default"])((0,F_weixin_wordc_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_2__["default"])({}, list[idx]), patch);
|
||||
setAddressList(list);
|
||||
}
|
||||
function deleteAddress(id) {
|
||||
var list = getAddressList().filter(function (a) {
|
||||
return a.id !== id;
|
||||
});
|
||||
setAddressList(list);
|
||||
}
|
||||
function getDefaultAddress() {
|
||||
return getAddressList().find(function (a) {
|
||||
return a.isDefault;
|
||||
});
|
||||
}
|
||||
|
||||
/***/ })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user