493 lines
21 KiB
JavaScript
493 lines
21 KiB
JavaScript
"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 ***!
|
|
\**********************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": function() { return /* binding */ ThemeToggle; }
|
|
/* harmony export */ });
|
|
/* 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_2__.useThemeContext)(),
|
|
theme = _useThemeContext.theme,
|
|
toggleTheme = _useThemeContext.toggleTheme;
|
|
var handleToggle = (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(function () {
|
|
toggleTheme();
|
|
// 触发全局事件,让其他页面也能感知(切换tab后回来的页面会重新读取storage)
|
|
_tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().eventCenter.trigger('theme:change');
|
|
}, [toggleTheme]);
|
|
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_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_4__.Text, {
|
|
className: "theme-icon",
|
|
children: theme === 'light' ? '🌙' : '☀️'
|
|
})
|
|
});
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/context/ThemeContext.tsx":
|
|
/*!**************************************!*\
|
|
!*** ./src/context/ThemeContext.tsx ***!
|
|
\**************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ ThemeProvider: function() { return /* binding */ ThemeProvider; },
|
|
/* harmony export */ useThemeContext: function() { return /* binding */ useThemeContext; }
|
|
/* harmony export */ });
|
|
/* unused harmony export ThemeContext */
|
|
/* harmony import */ var F_weixin_wordc_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js */ "./node_modules/@babel/runtime/helpers/esm/slicedToArray.js");
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/cjs/react.production.min.js");
|
|
/* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tarojs/taro */ "./node_modules/@tarojs/taro/index.js");
|
|
/* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var _utils_store__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/store */ "./src/utils/store.ts");
|
|
/* 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");
|
|
|
|
|
|
|
|
|
|
|
|
var ThemeContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)({
|
|
theme: 'light',
|
|
toggleTheme: function toggleTheme() {},
|
|
setTheme: function setTheme() {}
|
|
});
|
|
|
|
function ThemeProvider(_ref) {
|
|
var children = _ref.children;
|
|
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)((0,_utils_store__WEBPACK_IMPORTED_MODULE_2__.getTheme)()),
|
|
_useState2 = (0,F_weixin_wordc_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_4__["default"])(_useState, 2),
|
|
theme = _useState2[0],
|
|
set = _useState2[1];
|
|
var setTheme = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (t) {
|
|
(0,_utils_store__WEBPACK_IMPORTED_MODULE_2__.setTheme)(t);
|
|
set(t);
|
|
}, []);
|
|
var toggleTheme = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
|
|
var next = theme === 'light' ? 'dark' : 'light';
|
|
setTheme(next);
|
|
}, [theme, setTheme]);
|
|
|
|
// 监听全局主题变化事件(用于已挂载但未重新渲染的页面)
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
var listener = function listener(next) {
|
|
return set(next);
|
|
};
|
|
_tarojs_taro__WEBPACK_IMPORTED_MODULE_1___default().eventCenter.on('theme:change', listener);
|
|
return function () {
|
|
_tarojs_taro__WEBPACK_IMPORTED_MODULE_1___default().eventCenter.off('theme:change', listener);
|
|
};
|
|
}, []);
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(ThemeContext.Provider, {
|
|
value: {
|
|
theme: theme,
|
|
toggleTheme: toggleTheme,
|
|
setTheme: setTheme
|
|
},
|
|
children: children
|
|
});
|
|
}
|
|
function useThemeContext() {
|
|
return (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(ThemeContext);
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/utils/productConfig.ts":
|
|
/*!************************************!*\
|
|
!*** ./src/utils/productConfig.ts ***!
|
|
\************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ CATEGORIES: function() { return /* binding */ CATEGORIES; },
|
|
/* harmony export */ getProductById: function() { return /* binding */ getProductById; }
|
|
/* harmony export */ });
|
|
/* unused harmony export PRODUCTS */
|
|
/**
|
|
* 产品品类配置文件
|
|
*
|
|
* ⚠️ 重要:当实际产品尺寸确定后,请修改本文件中的 mask 参数
|
|
* 修改后页面会自动生效,无需改动其他代码
|
|
*/
|
|
|
|
var PRODUCTS = [{
|
|
id: 'notebook-small',
|
|
name: '微雕笔记本(小)',
|
|
desc: '便携随行,记录点滴',
|
|
icon: '📓',
|
|
price: 12,
|
|
leadTime: '3-5个工作日',
|
|
description: '精选优质纸张,封面采用高档PU材质,手感细腻。内页可定制横线、方格或空白三种版式。激光微雕工艺将名字或图案精准刻印在封面,永不褪色。小巧轻便,适合随身携带,无论是课堂笔记还是日常备忘,都是你的专属伴侣。',
|
|
images: ['/img/book_small/The1.png'],
|
|
mask: {
|
|
shape: 'rect',
|
|
width: 300,
|
|
height: 420,
|
|
borderRadius: 8
|
|
}
|
|
}, {
|
|
id: 'notebook-large',
|
|
name: '微雕笔记本(大)',
|
|
desc: '大开本,更多创作空间',
|
|
icon: '📔',
|
|
price: 45,
|
|
leadTime: '3-5个工作日',
|
|
description: 'A4尺寸大开本,180°平摊设计,书写更自由。封面可选真皮、仿布纹或磨砂材质,激光微雕区域更大,适合呈现全班名字、团队口号或公司Logo等大篇幅内容。是毕业纪念、企业年会礼品的首选。',
|
|
images: ['/img/book_big/The1.png', '/img/book_big/The2.png'],
|
|
mask: {
|
|
shape: 'rect',
|
|
width: 340,
|
|
height: 480,
|
|
borderRadius: 8
|
|
}
|
|
}, {
|
|
id: 'coaster',
|
|
name: '铜质杯垫',
|
|
desc: '金属质感,桌面艺术',
|
|
icon: '☕',
|
|
price: 25,
|
|
leadTime: '5-7个工作日',
|
|
description: '采用优质黄铜材质,表面经拉丝工艺处理,呈现哑光金属质感。背面配有防滑软木垫,保护桌面同时防止滑动。激光微雕可在表面刻印名字、日期或祝福语,是乔迁新居、新婚贺礼的精致之选。',
|
|
images: ['/img/cup/The1.jpg'],
|
|
mask: {
|
|
shape: 'circle',
|
|
width: 280,
|
|
height: 280
|
|
}
|
|
}, {
|
|
id: 'penbox',
|
|
name: '竹制笔盒',
|
|
desc: '自然竹纹,文房雅器',
|
|
icon: '✏️',
|
|
price: 75,
|
|
leadTime: '7-10个工作日',
|
|
description: '精选天然楠竹,经多道工序打磨抛光,保留天然竹纹肌理。盒盖采用磁吸开合,内部设有分层隔板。激光微雕在竹面上呈现深浅不一的雕刻效果,融入墨香气质。适合书房案头、书法爱好者的文房伴侣。',
|
|
images: ['/img/penbox/The1.png', '/img/penbox/The2.png', '/img/penbox/The3.jpg'],
|
|
mask: {
|
|
shape: 'rect',
|
|
width: 320,
|
|
height: 160,
|
|
borderRadius: 12
|
|
}
|
|
}, {
|
|
id: 'booklamp',
|
|
name: '书本型灯',
|
|
desc: '温暖光影,点亮心意',
|
|
icon: '💡',
|
|
price: 45,
|
|
leadTime: '5-7个工作日',
|
|
description: '开合式设计,打开即亮,合拢即灭,如魔法书般充满惊喜。采用LED暖光灯源,光线柔和不刺眼,可持续点亮6-8小时。封面激光微雕可定制文字、图案或照片,让温暖的灯光承载专属记忆。是情侣礼物、毕业礼物的创意之选。',
|
|
images: ['/img/booklight/The1.jpg', '/img/booklight/The2.jpg'],
|
|
mask: {
|
|
shape: 'rect',
|
|
width: 320,
|
|
height: 240,
|
|
borderRadius: 4
|
|
}
|
|
}];
|
|
|
|
/** CATEGORIES 为 PRODUCTS 的别名,供页面引用 */
|
|
var CATEGORIES = PRODUCTS;
|
|
|
|
/**
|
|
* 根据产品ID查找品类配置
|
|
*/
|
|
var getProductById = function getProductById(id) {
|
|
return PRODUCTS.find(function (p) {
|
|
return p.id === id;
|
|
});
|
|
};
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/utils/store.ts":
|
|
/*!****************************!*\
|
|
!*** ./src/utils/store.ts ***!
|
|
\****************************/
|
|
/***/ (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; },
|
|
/* harmony export */ getUserInfo: function() { return /* binding */ getUserInfo; },
|
|
/* 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 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");
|
|
/* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
|
|
|
|
|
var THEME_KEY = 'smart_theme';
|
|
var USER_KEY = 'smart_user_info';
|
|
var ACTIVE_USER_KEY = 'smart_active_openid';
|
|
|
|
// ---------- 当前用户 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(USER_KEY);
|
|
} catch (_unused) {
|
|
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();
|
|
}
|
|
|
|
// ---------- 设计清单 ----------
|
|
|
|
function getDesignList() {
|
|
try {
|
|
return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync(key('design_list')) || [];
|
|
} catch (_unused2) {
|
|
return [];
|
|
}
|
|
}
|
|
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(),
|
|
productId: product.id,
|
|
productName: product.name,
|
|
productIcon: product.icon,
|
|
unitPrice: product.price,
|
|
count: count,
|
|
status: 'undesigned',
|
|
createdAt: new Date().toISOString().slice(0, 10)
|
|
};
|
|
setDesignList([].concat((0,F_weixin_wordc_node_modules_babel_runtime_helpers_esm_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_1__["default"])(list), [item]));
|
|
return item;
|
|
}
|
|
function updateDesign(id, patch) {
|
|
var list = getDesignList();
|
|
var idx = list.findIndex(function (d) {
|
|
return d.id === id;
|
|
});
|
|
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);
|
|
}
|
|
|
|
// ---------- 订单 ----------
|
|
|
|
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) {
|
|
return d.id === designId;
|
|
});
|
|
if (!design) return null;
|
|
var order = {
|
|
id: 'ORD' + Date.now().toString().slice(-9),
|
|
productName: design.productName,
|
|
productIcon: design.productIcon,
|
|
statusCode: 'pending',
|
|
date: new Date().toLocaleString('zh-CN', {
|
|
month: '2-digit',
|
|
day: '2-digit',
|
|
hour: '2-digit',
|
|
minute: '2-digit'
|
|
}).replace(/\//g, '-'),
|
|
price: '¥' + (design.unitPrice * design.count).toFixed(2),
|
|
count: design.count,
|
|
sku: "".concat(design.productName, " \xD7 ").concat(design.count)
|
|
};
|
|
var dIdx = dList.findIndex(function (d) {
|
|
return d.id === designId;
|
|
});
|
|
if (dIdx !== -1) {
|
|
dList[dIdx].status = 'ordered';
|
|
dList[dIdx].orderId = order.id;
|
|
}
|
|
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;
|
|
}
|
|
|
|
// ---------- 主题 ----------
|
|
|
|
function getTheme() {
|
|
try {
|
|
return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorageSync(THEME_KEY) || 'light';
|
|
} catch (_unused4) {
|
|
return 'light';
|
|
}
|
|
}
|
|
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;
|
|
});
|
|
}
|
|
|
|
/***/ })
|
|
|
|
}]);
|
|
//# sourceMappingURL=common.js.map
|