commit 549435671a21d141ce7ff7d31c73f37de0a8de9a Author: kaeery <3491123437@qq.com> Date: Mon Jan 20 17:47:46 2025 +0800 【小程序】 新增# 项目初始化 diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..86f5ee0 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,39 @@ +/* eslint-env node */ +require('@rushstack/eslint-patch/modern-module-resolution') + +module.exports = { + root: true, + ignorePatterns: ['src/uni_modules/'], + extends: [ + 'plugin:vue/vue3-essential', + 'eslint:recommended', + '@vue/eslint-config-typescript/recommended', + '@vue/eslint-config-prettier' + ], + rules: { + 'prettier/prettier': [ + 'warn', + { + semi: false, + singleQuote: true, + printWidth: 100, + proseWrap: 'preserve', + bracketSameLine: false, + endOfLine: 'lf', + tabWidth: 4, + useTabs: false, + trailingComma: 'none' + } + ], + 'vue/multi-word-component-names': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/ban-ts-comment': 'off', + 'no-undef': 'off', + 'vue/prefer-import-from-vue': 'off', + 'no-prototype-builtins': 'off', + 'prefer-spread': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-non-null-asserted-optional-chain': 'off' + }, + globals: {} +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b197880 --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +coverage +*.local +dist + + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? +.hbuilderx +# .env +.env.development +.env.production +yarn.lock +package-lock.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..91f12b2 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..812d603 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,26 @@ +{ + "editor.detectIndentation": false, + "editor.tabSize": 4, + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, + "css.validate": false, + "less.validate": false, + "scss.validate": false, + "prettier.printWidth": 100, // 超过最大值换行 + "prettier.tabWidth": 4, // 缩进字节数 + "prettier.useTabs": false, // 缩进不使用tab,使用空格 + "prettier.semi": false, // 句尾添加分号 + "prettier.singleQuote": true, // 使用单引号代替双引号 + "prettier.proseWrap": "preserve", // 默认值。因为使用了一些折行敏感型的渲染器(如GitHub comment)而按照markdown文本样式进行折行 + "prettier.arrowParens": "avoid", // (x) => {} 箭头函数参数只有一个时是否要有小括号。avoid:省略括号 + "prettier.bracketSpacing": true, // 在对象,数组括号与文字之间加空格 "{ foo: bar }" + + "prettier.endOfLine": "auto", // 结尾是 \n \r \n\r auto + "prettier.htmlWhitespaceSensitivity": "ignore", + "prettier.ignorePath": ".prettierignore", // 不使用prettier格式化的文件填写在项目的.prettierignore文件中 + "prettier.jsxSingleQuote": false, // 在jsx中使用单引号代替双引号 + "prettier.requireConfig": false, // Require a 'prettierconfig' to format prettier + "prettier.trailingComma": "none" // 函数最后不需要逗号 +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..60d0627 --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + + + + + + + + +
+ + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..de8a237 --- /dev/null +++ b/package.json @@ -0,0 +1,82 @@ +{ + "name": "uni-preset-vue", + "version": "0.0.0", + "scripts": { + "dev:app": "uni -p app", + "dev:custom": "uni -p", + "dev:h5": "uni", + "dev:h5:ssr": "uni --ssr", + "dev:mp-alipay": "uni -p mp-alipay", + "dev:mp-baidu": "uni -p mp-baidu", + "dev:mp-kuaishou": "uni -p mp-kuaishou", + "dev:mp-lark": "uni -p mp-lark", + "dev:mp-qq": "uni -p mp-qq", + "dev:mp-toutiao": "uni -p mp-toutiao", + "dev:mp-weixin": "uni -p mp-weixin", + "dev:quickapp-webview": "uni -p quickapp-webview", + "dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei", + "dev:quickapp-webview-union": "uni -p quickapp-webview-union", + "build:app": "uni build -p app", + "build:custom": "uni build -p", + "build:h5": "node scripts/build.h5.mjs", + "build:h5:ssr": "uni build --ssr", + "build:mp-alipay": "uni build -p mp-alipay", + "build:mp-baidu": "uni build -p mp-baidu", + "build:mp-kuaishou": "uni build -p mp-kuaishou", + "build:mp-lark": "uni build -p mp-lark", + "build:mp-qq": "uni build -p mp-qq", + "build:mp-toutiao": "uni build -p mp-toutiao", + "build:mp-weixin": "uni build -p mp-weixin", + "build:quickapp-webview": "uni build -p quickapp-webview", + "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei", + "build:quickapp-webview-union": "uni build -p quickapp-webview-union", + "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" + }, + "dependencies": { + "@dcloudio/uni-app": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-app-plus": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-components": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-h5": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-mp-alipay": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-mp-baidu": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-mp-kuaishou": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-mp-lark": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-mp-qq": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-mp-toutiao": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-mp-weixin": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-quickapp-webview": "^3.0.0-alpha-3050520220824001", + "enumtor": "^1.0.5", + "lodash-es": "^4.17.21", + "pinia": "^2.0.20", + "vconsole": "^3.14.6", + "vue": "^3.2.37", + "vue-i18n": "^9.2.2", + "weixin-js-sdk": "^1.6.0", + "z-paging": "^2.3.8" + }, + "devDependencies": { + "@dcloudio/types": "^3.0.13", + "@dcloudio/uni-automator": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-cli-shared": "^3.0.0-alpha-3050520220824001", + "@dcloudio/uni-stacktracey": "^3.0.0-alpha-3050520220824001", + "@dcloudio/vite-plugin-uni": "^3.0.0-alpha-3050520220824001", + "@rushstack/eslint-patch": "^1.1.4", + "@types/lodash-es": "^4.17.6", + "@types/node": "^18.7.16", + "@vue/eslint-config-prettier": "^7.0.0", + "@vue/eslint-config-typescript": "^11.0.0", + "autoprefixer": "^10.4.8", + "eslint": "^8.22.0", + "eslint-plugin-vue": "^9.4.0", + "execa": "^6.1.0", + "fs-extra": "^10.1.0", + "postcss": "^8.4.16", + "postcss-rem-to-responsive-pixel": "^5.1.3", + "prettier": "^2.7.1", + "sass": "^1.54.5", + "tailwindcss": "^3.1.8", + "typescript": "^4.7.4", + "vite": "^2.9.14", + "weapp-tailwindcss-webpack-plugin": "^1.7.0" + } +} diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..0d26655 --- /dev/null +++ b/project.config.json @@ -0,0 +1,29 @@ +{ + "compileType": "miniprogram", + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "ignoreUploadUnusedFiles": true + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 2 + }, + "libVersion": "3.0.0", + "packOptions": { + "ignore": [], + "include": [] + }, + "appid": "wxf712ba4cbc2df1e9" +} \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..129c450 --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "housekeeping-uniapp", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/scripts/build.h5.mjs b/scripts/build.h5.mjs new file mode 100644 index 0000000..eb4ade6 --- /dev/null +++ b/scripts/build.h5.mjs @@ -0,0 +1,37 @@ +import { execaCommand } from 'execa' +import path from 'path' +import fsExtra from 'fs-extra' +const { existsSync, remove, copy } = fsExtra +const cwd = process.cwd() +//打包发布路径,谨慎改动 +const releaseRelativePath = '../public/mobile' +const distPath = path.resolve(cwd, 'dist/build/h5') +const releasePath = path.resolve(cwd, releaseRelativePath) + +async function build() { + await execaCommand('uni build', { stdio: 'inherit', encoding: 'utf-8', cwd }) + if (existsSync(releasePath)) { + await remove(releasePath) + } + console.log(`文件正在复制 ==> ${releaseRelativePath}`) + try { + await copyFile(distPath, releasePath) + } catch (error) { + console.log(`\n ${error}`) + } + console.log(`文件已复制 ==> ${releaseRelativePath}`) +} + +function copyFile(sourceDir, targetDir) { + return new Promise((resolve, reject) => { + copy(sourceDir, targetDir, (err) => { + if (err) { + reject(err) + } else { + resolve() + } + }) + }) +} + +build() diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..6360aef --- /dev/null +++ b/src/App.vue @@ -0,0 +1,32 @@ + + diff --git a/src/api/account.ts b/src/api/account.ts new file mode 100644 index 0000000..365c33a --- /dev/null +++ b/src/api/account.ts @@ -0,0 +1,26 @@ +import { client } from '@/utils/client' +import request from '@/utils/request' + +// 登录 +export function login(data: Record) { + return request.post({ url: '/login/check', data: { ...data, client } }) +} + +//注册 +export function register(data: Record) { + return request.post({ url: '/login/register', data: { ...data, client } }) +} + +//忘记密码 +export function forgotPassword(data: Record) { + return request.post({ url: '/login/forgotPassword', data }) +} + +//向微信请求code的链接 +export function getWxCodeUrl() { + return request.get({ url: '/login/codeUrl', data: { url: location.href } }) +} + +export function OALogin(data: Record) { + return request.get({ url: '/login/oaLogin', data }) +} diff --git a/src/api/app.ts b/src/api/app.ts new file mode 100644 index 0000000..0909bf5 --- /dev/null +++ b/src/api/app.ts @@ -0,0 +1,99 @@ +import request from '@/utils/request' +// #ifdef H5 +import { getSignLink } from '@/hooks/wechat' +// #endif + +//发送短信 +export function smsSend(data: any) { + return request.post({ url: '/sms/send', data: data }) +} + +// 获取公共配置 +export function getConfig() { + return request.get({ url: '/config' }) +} + +// 访问量 +export const apiIndexVisit = (params: any) => request.get({ url: '/index/visit', data: params }) + +// 获取政策协议 +export function getPolicy(data: any) { + return request.get({ url: '/policy', data: data }) +} + +// 获取客服信息 +export function apiContactService(data: any) { + return request.get({ url: '/decorate/pages/service', data: data }, { isAuth: true }) +} + +// 公众号登录 +export const apiOALogin = (params: any) => request.post({ url: '/login/oaLogin', data: params }) + +// 公众号-获取授权url +export const apiCodeUrlGet = () => + request.get({ + url: '/login/codeUrl', + data: { + url: location.href, + headers: { 1: 1 } + } + }) + +// 获取城市信息-字母分组 +export const apiCityInfo = (params: any) => request.get({ url: '/region/city', data: params }) + +// 微信sdk配置 +export const apiJsConfig = (data: any) => + request.get({ url: '/wechat/jsConfig', data: { url: getSignLink() } }) + +/** + * @param { Object } params { address: 广州市番禺区xxx } + * @return { Promise } + * @description 地址逆解析 + */ +export const getGeocoder = (params: any) => + request.get({ url: '/region/keyWordAddress', data: params }) + +/** + * @param { Object } params { location: xxx,xxx } + * @return { Promise } + * @description 地址逆解析 + */ +export const getGeocoderCoordinate = (params: any) => + request.post({ url: '/region/genCoder', data: params }) + +// 支付方式 +export const apiPayPayWay = (params: any) => + request.get({ url: '/order/pay/way/list', data: params }) + +// 预支付 +export const apiPayPrepay = (params: any) => request.post({ url: '/pay/wx/prePay', data: params }) + +// h5预支付 +export const apiH5PayPrepay = (params: any) => request.post({ url: '/pay/h5/prePay', data: params }) +// DY 预支付 +export const apiBytePayPrepay = (params: any) => + request.post({ url: '/pay/byte/createOrder', data: params }) +// DY 更新订单状态 +export const apiByteQueryOrder = (params: any) => + request.post({ url: '/pay/byte/queryOrder', data: params }) + +// 充值支付接口 +export const apiRechargeOrder = (params: any) => + request.post({ url: '/pay/wx/prePay', data: params }) + +// 查询订单 +export const apiQueryOrder = (params: any) => + request.get({ url: '/order/pay/status', data: params }) + +// 查询充值记录 +export const apiQueryRechargeList = (params: any) => + request.get({ url: '/recharge/record', data: params }) + +// 查询充值状态 +export const apiQueryRecharge = (params: any) => + request.get({ url: '/recharge/payStatus', data: params }) + +// 绑定分销员id +export const apiBindingDistId = (params: any) => + request.post({ url: '/user/bindDistributor', data: params }) diff --git a/src/api/coupon.ts b/src/api/coupon.ts new file mode 100644 index 0000000..42375a8 --- /dev/null +++ b/src/api/coupon.ts @@ -0,0 +1,28 @@ +import request from '@/utils/request' + +// 获取我的优惠券 +export const apiMyCouponList = (params) => request.get({ url: '/coupon/myCoupon', data: params }) + +// 领券中心 +export const apiCouponCenterList = (params) => request.get({ url: '/coupon/list', data: params }) + +// 优惠券详情 +export const apiCouponDetail = (params) => request.get({ url: '/coupon/detail', data: params }) + +// 领取优惠券 +export const apiCouponManualGet = (params) => request.post({ url: '/coupon/getCoupon', data: params }) + +// 品类券对应商品 +export const apiCouponCategoryGoods = (params) => request.get({ url: '/coupon/deductionGoodsCategory', data: params }) + +// 商品券对应商品 +export const apiCouponGoods = (params) => request.get({ url: '/coupon/deductionGoods', data: params }) + +// 下单获取最大优惠 +export const apiCouponMaxMoney = (params) => request.get({ url: '/coupon/maxDiscounts', data: params }) + +// 可用优惠券+不可用优惠券 +export const apiCouponByUse = (params) => request.get({ url: '/coupon/selectCoupon', data: params }) + +// 可用优惠券+不可用优惠券数量 +export const apiCouponCount = (params) => request.get({ url: '/coupon/selectCouponCount', data: params }) diff --git a/src/api/distributor_center.ts b/src/api/distributor_center.ts new file mode 100644 index 0000000..45397be --- /dev/null +++ b/src/api/distributor_center.ts @@ -0,0 +1,34 @@ +import request from '@/utils/request' + +/**获取分销商数据 */ +export function getDistributorCenter(params) { + return request.get({ url: '/distributor/myDistributor', data: params }) +} +/**获取月份账单 */ +export function getDistributorOrder(params) { + return request.get({ url: '/distributor/distributorOrder', data: params }) +} +/**获取月份账单详情 */ +export function getDistributorOrderDetail(params) { + return request.get({ url: '/distributor/distributorOrderDetail', data: params }) +} +/**获取提现记录 */ +export function getDistributorWithDrawList(params) { + return request.get({ url: '/distributor/withdrawalRecord', data: params }) +} +/**分享太阳码 */ +export function getDistributorQrcode(params) { + return request.get({ url: '/distributor/distributorQrCode', data: params }) +} +/**获取分销用户 */ +export function getDistributorBindingUser(params) { + return request.get({ url: '/distributor/getDistributorUser', data: params }) +} +/**获取分销订单-月份总金额 */ +export function getDistributorOrderByMonth(params) { + return request.get({ url: '/distributor/distributorOrderByMonth', data: params }) +} +/**获取分销用户-月份分销总用户 */ +export function getDistributorUserByMonth(params) { + return request.get({ url: '/distributor/distributorUserByMonth', data: params }) +} diff --git a/src/api/goods.ts b/src/api/goods.ts new file mode 100644 index 0000000..532f650 --- /dev/null +++ b/src/api/goods.ts @@ -0,0 +1,55 @@ +/* + * @Author: micky 1254597151@qq.com + * @Date: 2023-08-14 15:38:40 + * @LastEditors: micky 1254597151@qq.com + * @LastEditTime: 2023-12-20 20:08:02 + * @FilePath: \housekeeping-uniapp\src\api\goods.ts + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import request from '@/utils/request' + +// 获取商品详情 +export const apiGoodsDetail = params => request.get({ url: '/goods/detail', data: params }) + +// 收藏列表 +export const apiCollectLists = () => request.get({ url: '/collect/list' }) + +// 商品收藏 +export const apiGoodsCollection = params => request.post({ url: '/collect/add', data: params }) + +// 取消收藏 +export const apiGoodsCollectionCancel = params => request.get({ url: '/collect/del', data: params }) + +// 获取预约时间列表 +export const apiAppointTime = (params = {}) => request.get({ url: '/time/getTime', data: params }) + +// 添加评价 +export const apiAddEvaluateGoods = (params = '') => + request.post({ url: '/comment/add', data: params }) + +// 获取商品评价列表 +export const apiEvaluateGoodsLists = (params: any) => + request.post({ url: '/comment/list', data: params }) + +// 待评价列表 +export const apiWaitEvaluateGoodsLists = (params: any) => + request.get({ url: '/order/wait/comment/list', data: params }, {}) + +// 获取商品评价统计数据-已评价、待评价 +export const apiEvaluateStatis = (params: any) => + request.get({ url: '/comment/statistics/user', data: params }) + +// 获取商品评价统计数据-好评、差评... +export const apiEvaluateGoodsStatis = (params: any) => + request.get({ url: '/comment/statistics/goods', data: params }) + +// 退单规则 +export const apiRuleList = (params: any) => + request.get({ url: '/goods/getCancelOrderGoodsConfig', data: params }) + +// 获取活动专区详情 +export const apiActivityDetail = (params: any) => + request.get({ url: '/activity/detail', data: params }) + +// 获取活动专区列表 +export const apiActivityList = (params: any) => request.get({ url: '/activity/list', data: params }) diff --git a/src/api/order.ts b/src/api/order.ts new file mode 100644 index 0000000..d2b6116 --- /dev/null +++ b/src/api/order.ts @@ -0,0 +1,56 @@ +import request from '@/utils/request' + +// 订单初始化 +export const apiInitOrder = (params: any) => request.get({ url: '/order/init', data: params }) + +// 订单下单 +export const apiPlaceOrder = (params: any) => request.post({ url: '/order/add', data: params }) + +// 订单列表 +export const apiOrderLists = (params: any) => + request.get({ url: '/order/list', data: params }, { ignoreCancel: true }) + +// 订单详情 +export const apiOrderDetail = (params: any) => request.get({ url: '/order/detail', data: params }) + +// 取消订单 +export const apiOrderCancel = (params: any) => request.post({ url: '/order/cancel', data: params }) + +// 删除订单 +export const apiOrderDel = (params: any) => request.get({ url: '/order/del', data: params }) + +// 关闭订单(取消支付) +export const apiOrderClose = (params: any) => + request.get({ url: '/pay/wx/closeOrder', data: params }) + +/** 师傅订单服务 Start **/ + +// 师傅服务列表 +export const apiStaffOrderLists = (params: any) => + request.get({ url: '/order/staff/list', data: params }, { ignoreCancel: true }) + +// 师傅服务详情 +export const apiStaffOrderDetail = (params: any) => + request.get({ url: '/order/detail', data: params }) + +// 确认服务 +export const apiStaffOrderConfirmService = (params: any) => + request.get({ url: '/order/staff/confirm', data: params }) + +// 核销订单 +export const apiStaffOrderVerification = (params: any) => + request.get({ url: '/order/staff/verification', data: params }) + +// 用户核销订单 +export const apiUserOrderVerification = (params: any) => + request.get({ url: '/order/user/verification', data: params }) + +/** 师傅订单服务 Start **/ + +// DY 取消更新状态 +export const apiByteQueryRefund = (params: any) => + request.post({ url: '/pay/byte/queryRefund', data: params }) + +// 取消订单扣分规则 +export const apiCancelOrderRule = (params: any) => + request.get({ url: '/order/getCancelOrderConfigByOrder', data: params }) diff --git a/src/api/shop.ts b/src/api/shop.ts new file mode 100644 index 0000000..0810f7b --- /dev/null +++ b/src/api/shop.ts @@ -0,0 +1,25 @@ +import request from '@/utils/request' + +//首页数据 +export function getIndex(data: any) { + return request.get({ url: '/index/index', data }) +} + +// 装修页面 +export function getDecorate(data: any) { + return request.get({ url: '/decorate', data }) +} + +// 热门搜索 +export function getHotSearch() { + return request.get({ url: '/hotSearch' }) +} + +/** + * @description 搜索 + * @param { string } keyword 关键词 + * @return { Promise } + */ +export function getSearch(data: { keyword: string; pageNo: number; pageSize: number }) { + return request.get({ url: '/search', data }) +} diff --git a/src/api/store.ts b/src/api/store.ts new file mode 100644 index 0000000..ab2a62b --- /dev/null +++ b/src/api/store.ts @@ -0,0 +1,77 @@ +/* + * @Author: micky 1254597151@qq.com + * @Date: 2023-08-14 15:38:40 + * @LastEditors: micky 1254597151@qq.com + * @LastEditTime: 2023-12-25 20:10:21 + * @FilePath: \housekeeping-uniapp\src\api\store.ts + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import request from '@/utils/request' + +/** + * @param { Object } params + * @return { Promise } + * @description 轮博图 + */ +export const apiAdLists = (params: any) => request.get({ url: '/ad/lists', data: params }) + +// 服务分类-分页列表 +export const apiCategoryLists = () => request.get({ url: '/category/list' }) + +// 商品服务分类-父级 +export const apiGoodsCategoryLists = (params: any) => + request.get({ url: '/category/commonList', data: params }) + +/** + * @param { Object } params + * @return { Promise } + * @description 服务列表 + */ +export const apiGoodsLists = (params: any) => + request.get({ url: '/goods/list', data: params }, { ignoreCancel: true }) + +/** + * @param { Object } params + * @return { Promise } + * @description 服务师傅列表 + */ +export const apiStaffLists = (params: any) => request.post({ url: '/staff/list', data: params }) + +/** + * @param { Object } params + * @return { Promise } + * @description 师傅详情 + */ +export const apiStaffDetail = (params: any) => request.get({ url: '/staff/detail', data: params }) + +/** + * @param { Object } params + * @return { Promise } + * @description 获取地级市列表 + */ +export const apiRegionCity = () => request.get({ url: '/region/char/city' }) + +/** + * @description 热门搜索 + * @return { Promise } + */ +export function getHotSearch() { + return request.get({ url: '/hotSearch' }) +} + +/** + * @description 搜索 + * @param { string } keyword 关键词 + * @return { Promise } + */ +export function getSearch(data: { keyword: string; pageNo: number; pageSize: number }) { + return request.get({ url: '/search', data }) +} + +/** + * @param { Object } params + * @return { Promise } + * @description 服务详情底部商品推荐 + */ +export const apiRecommendService = (params: any) => + request.get({ url: '/goods/recommendationList', data: params }) diff --git a/src/api/user.ts b/src/api/user.ts new file mode 100644 index 0000000..6b6b444 --- /dev/null +++ b/src/api/user.ts @@ -0,0 +1,54 @@ +import request from '@/utils/request' + +export function getUserCenter(header?: any) { + return request.get({ url: '/user/center', header }) +} + +// 个人信息 +export function getUserInfo() { + return request.get({ url: '/user/info' }, { isAuth: true }) +} + +// 个人编辑 +export function userEdit(data: any) { + return request.post({ url: '/user/edit', data }, { isAuth: true }) +} + +// 绑定手机 +export function userBindMobile(data: any, header?: any) { + return request.post({ url: '/user/bindMobile', data, header }, { isAuth: true }) +} + +// 微信电话 +export function userMnpMobile(data: any) { + return request.post({ url: '/user/mnpMobile', data }, { isAuth: true }) +} + +// 更改密码 +export function userChangePwd(data: any) { + return request.post({ url: '/user/changePwd', data }, { isAuth: true }) +} + +// 地址列表 +export const apiAddressLists = () => request.get({ url: '/address/list' }) + +// 获取地址详情 +export const apiAddressDetail = (params: any) => + request.get({ url: '/address/detail', data: params }) + +// 编辑地址 +export const apiAddressEdit = (params: any) => request.post({ url: '/address/edit', data: params }) + +// 新增地址 +export const apiAddressAdd = (params: any) => request.post({ url: '/address/add', data: params }) + +// 删除地址 +export const apiAddressDel = (params: any) => request.get({ url: '/address/del', data: params }) + +// 提交订单 +export const apiEvaluateAdd = (params: any) => request.post({ url: '/comment/add', data: params }) + +//更新微信小程序头像昵称 +export function updateUser(data: Record, header: any) { + return request.post({ url: '/user/updateUser', data, header }) +} diff --git a/src/api/wallet.ts b/src/api/wallet.ts new file mode 100644 index 0000000..fd9b24f --- /dev/null +++ b/src/api/wallet.ts @@ -0,0 +1,48 @@ +/* + * @Author: micky 1254597151@qq.com + * @Date: 2023-08-14 15:38:40 + * @LastEditors: micky 1254597151@qq.com + * @LastEditTime: 2024-01-28 16:20:42 + * @FilePath: \housekeeping-uniapp\src\api\wallet.ts + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import request from '@/utils/request' + +// 钱包信息 +export const apiUserWallet = (params: any) => request.get({ url: '/recharge/config', data: params }) + +// 账户明细列表 +export const apiAccountLogLists = (params: any) => + request.get({ url: '/account/log/list', data: params }, { ignoreCancel: true }) + +// 充值 +export const apiRecharge = (params: any) => + request.post({ url: '/recharge/placeOrder', data: params }) + +// 充值记录列表 +export const apiRechargeLogLists = (params: any) => + request.get({ url: '/recharge/record', data: params }) + +// 获取提现配置 +export const apiGetWithdrawConfig = (params: any) => + request.get({ url: '/withdraw/getConfig', data: params }) + +// 提现申请 +export const apiWithdrawApply = (params: any) => + request.post({ url: '/withdraw/apply', data: params }) + +// 提现申请列表 +export const apiWithdrawLists = (params: any) => + request.get({ url: '/withdraw/lists', data: params }) + +// 提现申请详情 +export const apiWithdrawDetail = (params: any) => + request.get({ url: '/withdraw/detail', data: params }) + +// 提现申请-不需要审核 +export const apiWithdrawCommission = (params: any) => + request.post({ url: '/distributor/withdrawCommission', data: params }) + +// 提现申请-新-需要审核 +export const applyForWithdraw = (params: any) => + request.post({ url: '/distributor/applyForAdd', data: params }) diff --git a/src/bundle/pages/account_detail/account_detail.vue b/src/bundle/pages/account_detail/account_detail.vue new file mode 100644 index 0000000..386b1f0 --- /dev/null +++ b/src/bundle/pages/account_detail/account_detail.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/src/bundle/pages/account_detail/components/list.vue b/src/bundle/pages/account_detail/components/list.vue new file mode 100644 index 0000000..608edaf --- /dev/null +++ b/src/bundle/pages/account_detail/components/list.vue @@ -0,0 +1,111 @@ + + + + + diff --git a/src/bundle/pages/appoint_time/index.vue b/src/bundle/pages/appoint_time/index.vue new file mode 100644 index 0000000..eee5033 --- /dev/null +++ b/src/bundle/pages/appoint_time/index.vue @@ -0,0 +1,266 @@ + + + + diff --git a/src/bundle/pages/category_goods_coupon/components/goodItem.vue b/src/bundle/pages/category_goods_coupon/components/goodItem.vue new file mode 100644 index 0000000..06ed1e3 --- /dev/null +++ b/src/bundle/pages/category_goods_coupon/components/goodItem.vue @@ -0,0 +1,98 @@ + + + + diff --git a/src/bundle/pages/category_goods_coupon/goods.vue b/src/bundle/pages/category_goods_coupon/goods.vue new file mode 100644 index 0000000..9697b02 --- /dev/null +++ b/src/bundle/pages/category_goods_coupon/goods.vue @@ -0,0 +1,62 @@ + + + + + \ No newline at end of file diff --git a/src/bundle/pages/category_goods_coupon/goods_category.vue b/src/bundle/pages/category_goods_coupon/goods_category.vue new file mode 100644 index 0000000..f7626e3 --- /dev/null +++ b/src/bundle/pages/category_goods_coupon/goods_category.vue @@ -0,0 +1,151 @@ + + + + + diff --git a/src/bundle/pages/category_goods_list/index.vue b/src/bundle/pages/category_goods_list/index.vue new file mode 100644 index 0000000..66ff7f1 --- /dev/null +++ b/src/bundle/pages/category_goods_list/index.vue @@ -0,0 +1,156 @@ + + + + + diff --git a/src/bundle/pages/city/index.vue b/src/bundle/pages/city/index.vue new file mode 100644 index 0000000..eacd8f9 --- /dev/null +++ b/src/bundle/pages/city/index.vue @@ -0,0 +1,456 @@ + + + + + diff --git a/src/bundle/pages/collection_list/index.vue b/src/bundle/pages/collection_list/index.vue new file mode 100644 index 0000000..4fba8c4 --- /dev/null +++ b/src/bundle/pages/collection_list/index.vue @@ -0,0 +1,110 @@ + + + + + + diff --git a/src/bundle/pages/contact_service/index.vue b/src/bundle/pages/contact_service/index.vue new file mode 100644 index 0000000..a0bbc27 --- /dev/null +++ b/src/bundle/pages/contact_service/index.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/bundle/pages/coupon/coupon_detail.vue b/src/bundle/pages/coupon/coupon_detail.vue new file mode 100644 index 0000000..7f3adc1 --- /dev/null +++ b/src/bundle/pages/coupon/coupon_detail.vue @@ -0,0 +1,275 @@ + + + + + \ No newline at end of file diff --git a/src/bundle/pages/coupon/index.vue b/src/bundle/pages/coupon/index.vue new file mode 100644 index 0000000..ee823ad --- /dev/null +++ b/src/bundle/pages/coupon/index.vue @@ -0,0 +1,72 @@ + + + + + diff --git a/src/bundle/pages/coupon_order/coupon_order.vue b/src/bundle/pages/coupon_order/coupon_order.vue new file mode 100644 index 0000000..2932081 --- /dev/null +++ b/src/bundle/pages/coupon_order/coupon_order.vue @@ -0,0 +1,234 @@ + + + + + diff --git a/src/bundle/pages/dist_order/index.vue b/src/bundle/pages/dist_order/index.vue new file mode 100644 index 0000000..00ce4e6 --- /dev/null +++ b/src/bundle/pages/dist_order/index.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/bundle/pages/distributor_binding_user/components/userCard.vue b/src/bundle/pages/distributor_binding_user/components/userCard.vue new file mode 100644 index 0000000..bceb247 --- /dev/null +++ b/src/bundle/pages/distributor_binding_user/components/userCard.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/src/bundle/pages/distributor_binding_user/index.vue b/src/bundle/pages/distributor_binding_user/index.vue new file mode 100644 index 0000000..3863d04 --- /dev/null +++ b/src/bundle/pages/distributor_binding_user/index.vue @@ -0,0 +1,127 @@ + + + + diff --git a/src/bundle/pages/distributor_order/components/orderCard.vue b/src/bundle/pages/distributor_order/components/orderCard.vue new file mode 100644 index 0000000..8454081 --- /dev/null +++ b/src/bundle/pages/distributor_order/components/orderCard.vue @@ -0,0 +1,108 @@ + + + + + diff --git a/src/bundle/pages/distributor_order/index.vue b/src/bundle/pages/distributor_order/index.vue new file mode 100644 index 0000000..9a1c0f1 --- /dev/null +++ b/src/bundle/pages/distributor_order/index.vue @@ -0,0 +1,134 @@ + + + + diff --git a/src/bundle/pages/evaluate_goods/components/card.vue b/src/bundle/pages/evaluate_goods/components/card.vue new file mode 100644 index 0000000..0ce275f --- /dev/null +++ b/src/bundle/pages/evaluate_goods/components/card.vue @@ -0,0 +1,127 @@ + + + + + diff --git a/src/bundle/pages/evaluate_goods/components/list.vue b/src/bundle/pages/evaluate_goods/components/list.vue new file mode 100644 index 0000000..7d2fb74 --- /dev/null +++ b/src/bundle/pages/evaluate_goods/components/list.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/src/bundle/pages/evaluate_goods/index.vue b/src/bundle/pages/evaluate_goods/index.vue new file mode 100644 index 0000000..9156d1b --- /dev/null +++ b/src/bundle/pages/evaluate_goods/index.vue @@ -0,0 +1,107 @@ + + + + + + diff --git a/src/bundle/pages/evaluate_list/components/already.vue b/src/bundle/pages/evaluate_list/components/already.vue new file mode 100644 index 0000000..3d7ead4 --- /dev/null +++ b/src/bundle/pages/evaluate_list/components/already.vue @@ -0,0 +1,144 @@ + + + + + diff --git a/src/bundle/pages/evaluate_list/components/alreadyList.vue b/src/bundle/pages/evaluate_list/components/alreadyList.vue new file mode 100644 index 0000000..36b2104 --- /dev/null +++ b/src/bundle/pages/evaluate_list/components/alreadyList.vue @@ -0,0 +1,83 @@ + + + diff --git a/src/bundle/pages/evaluate_list/components/list.vue b/src/bundle/pages/evaluate_list/components/list.vue new file mode 100644 index 0000000..9695da8 --- /dev/null +++ b/src/bundle/pages/evaluate_list/components/list.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/src/bundle/pages/evaluate_list/components/wait.vue b/src/bundle/pages/evaluate_list/components/wait.vue new file mode 100644 index 0000000..24e099b --- /dev/null +++ b/src/bundle/pages/evaluate_list/components/wait.vue @@ -0,0 +1,82 @@ + + + + + + diff --git a/src/bundle/pages/evaluate_list/index.vue b/src/bundle/pages/evaluate_list/index.vue new file mode 100644 index 0000000..b629327 --- /dev/null +++ b/src/bundle/pages/evaluate_list/index.vue @@ -0,0 +1,106 @@ + + + + + diff --git a/src/bundle/pages/evaluate_submit/index.vue b/src/bundle/pages/evaluate_submit/index.vue new file mode 100644 index 0000000..56e8e2f --- /dev/null +++ b/src/bundle/pages/evaluate_submit/index.vue @@ -0,0 +1,164 @@ + + + + + diff --git a/src/bundle/pages/master_worker_detail/index.vue b/src/bundle/pages/master_worker_detail/index.vue new file mode 100644 index 0000000..c33965a --- /dev/null +++ b/src/bundle/pages/master_worker_detail/index.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/src/bundle/pages/master_worker_list/index.vue b/src/bundle/pages/master_worker_list/index.vue new file mode 100644 index 0000000..683558a --- /dev/null +++ b/src/bundle/pages/master_worker_list/index.vue @@ -0,0 +1,148 @@ + + + + + diff --git a/src/bundle/pages/my_coupon/components/list.vue b/src/bundle/pages/my_coupon/components/list.vue new file mode 100644 index 0000000..240d56f --- /dev/null +++ b/src/bundle/pages/my_coupon/components/list.vue @@ -0,0 +1,136 @@ + + + + + diff --git a/src/bundle/pages/my_coupon/my_coupon.vue b/src/bundle/pages/my_coupon/my_coupon.vue new file mode 100644 index 0000000..f25c43f --- /dev/null +++ b/src/bundle/pages/my_coupon/my_coupon.vue @@ -0,0 +1,73 @@ + + + + + diff --git a/src/bundle/pages/my_distributor/my_distributor.vue b/src/bundle/pages/my_distributor/my_distributor.vue new file mode 100644 index 0000000..c7e3a10 --- /dev/null +++ b/src/bundle/pages/my_distributor/my_distributor.vue @@ -0,0 +1,295 @@ + + + + diff --git a/src/bundle/pages/receive_coupon/receive_coupon.vue b/src/bundle/pages/receive_coupon/receive_coupon.vue new file mode 100644 index 0000000..a96fe7e --- /dev/null +++ b/src/bundle/pages/receive_coupon/receive_coupon.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/src/bundle/pages/recharge_record/recharge_record.vue b/src/bundle/pages/recharge_record/recharge_record.vue new file mode 100644 index 0000000..c141d91 --- /dev/null +++ b/src/bundle/pages/recharge_record/recharge_record.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/src/bundle/pages/search/component/suggest.vue b/src/bundle/pages/search/component/suggest.vue new file mode 100644 index 0000000..b52009a --- /dev/null +++ b/src/bundle/pages/search/component/suggest.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/src/bundle/pages/search/index.vue b/src/bundle/pages/search/index.vue new file mode 100644 index 0000000..fc88bc8 --- /dev/null +++ b/src/bundle/pages/search/index.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/src/bundle/pages/service_explain/index.vue b/src/bundle/pages/service_explain/index.vue new file mode 100644 index 0000000..f66e98a --- /dev/null +++ b/src/bundle/pages/service_explain/index.vue @@ -0,0 +1,60 @@ + + + + + + diff --git a/src/bundle/pages/service_order/components/order-card.vue b/src/bundle/pages/service_order/components/order-card.vue new file mode 100644 index 0000000..60c9cb6 --- /dev/null +++ b/src/bundle/pages/service_order/components/order-card.vue @@ -0,0 +1,146 @@ + + + + + diff --git a/src/bundle/pages/service_order/components/order-list.vue b/src/bundle/pages/service_order/components/order-list.vue new file mode 100644 index 0000000..9f2dbbb --- /dev/null +++ b/src/bundle/pages/service_order/components/order-list.vue @@ -0,0 +1,101 @@ + + + + + diff --git a/src/bundle/pages/service_order/index.vue b/src/bundle/pages/service_order/index.vue new file mode 100644 index 0000000..7250ce3 --- /dev/null +++ b/src/bundle/pages/service_order/index.vue @@ -0,0 +1,111 @@ + + + + + + diff --git a/src/bundle/pages/service_order_detail/index.vue b/src/bundle/pages/service_order_detail/index.vue new file mode 100644 index 0000000..a389d31 --- /dev/null +++ b/src/bundle/pages/service_order_detail/index.vue @@ -0,0 +1,261 @@ + + + + + diff --git a/src/bundle/pages/share_qrcode/index.vue b/src/bundle/pages/share_qrcode/index.vue new file mode 100644 index 0000000..b421d98 --- /dev/null +++ b/src/bundle/pages/share_qrcode/index.vue @@ -0,0 +1,216 @@ + + + + diff --git a/src/bundle/pages/user_address/index.vue b/src/bundle/pages/user_address/index.vue new file mode 100644 index 0000000..1e1a9c7 --- /dev/null +++ b/src/bundle/pages/user_address/index.vue @@ -0,0 +1,240 @@ + + + + diff --git a/src/bundle/pages/user_address_edit/index.vue b/src/bundle/pages/user_address_edit/index.vue new file mode 100644 index 0000000..f471d04 --- /dev/null +++ b/src/bundle/pages/user_address_edit/index.vue @@ -0,0 +1,336 @@ + + + + diff --git a/src/bundle/pages/user_recharge/user_recharge.vue b/src/bundle/pages/user_recharge/user_recharge.vue new file mode 100644 index 0000000..1c1347b --- /dev/null +++ b/src/bundle/pages/user_recharge/user_recharge.vue @@ -0,0 +1,216 @@ + + + + + diff --git a/src/bundle/pages/user_wallet/user_wallet.vue b/src/bundle/pages/user_wallet/user_wallet.vue new file mode 100644 index 0000000..7c48ffd --- /dev/null +++ b/src/bundle/pages/user_wallet/user_wallet.vue @@ -0,0 +1,183 @@ + + + + diff --git a/src/bundle/pages/user_withdraw/user_withdraw.vue b/src/bundle/pages/user_withdraw/user_withdraw.vue new file mode 100644 index 0000000..c306d3f --- /dev/null +++ b/src/bundle/pages/user_withdraw/user_withdraw.vue @@ -0,0 +1,342 @@ + + + + + diff --git a/src/bundle/pages/withdraw_distributor_record/components/card.vue b/src/bundle/pages/withdraw_distributor_record/components/card.vue new file mode 100644 index 0000000..962c311 --- /dev/null +++ b/src/bundle/pages/withdraw_distributor_record/components/card.vue @@ -0,0 +1,113 @@ + + + + + diff --git a/src/bundle/pages/withdraw_distributor_record/index.vue b/src/bundle/pages/withdraw_distributor_record/index.vue new file mode 100644 index 0000000..d4e8220 --- /dev/null +++ b/src/bundle/pages/withdraw_distributor_record/index.vue @@ -0,0 +1,130 @@ + + + + + diff --git a/src/bundle/pages/withdraw_money/index.vue b/src/bundle/pages/withdraw_money/index.vue new file mode 100644 index 0000000..50e538e --- /dev/null +++ b/src/bundle/pages/withdraw_money/index.vue @@ -0,0 +1,227 @@ + + + + diff --git a/src/bundle/pages/withdraw_record/components/card.vue b/src/bundle/pages/withdraw_record/components/card.vue new file mode 100644 index 0000000..584dd1c --- /dev/null +++ b/src/bundle/pages/withdraw_record/components/card.vue @@ -0,0 +1,98 @@ + + + + + diff --git a/src/bundle/pages/withdraw_record/components/list.vue b/src/bundle/pages/withdraw_record/components/list.vue new file mode 100644 index 0000000..f2c17b8 --- /dev/null +++ b/src/bundle/pages/withdraw_record/components/list.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/bundle/pages/withdraw_record/withdraw_record.vue b/src/bundle/pages/withdraw_record/withdraw_record.vue new file mode 100644 index 0000000..d12ef0b --- /dev/null +++ b/src/bundle/pages/withdraw_record/withdraw_record.vue @@ -0,0 +1,23 @@ + + + + + diff --git a/src/bundle/pages/withdrawal_details/withdrawal_details.vue b/src/bundle/pages/withdrawal_details/withdrawal_details.vue new file mode 100644 index 0000000..70194b0 --- /dev/null +++ b/src/bundle/pages/withdrawal_details/withdrawal_details.vue @@ -0,0 +1,307 @@ + + + + + diff --git a/src/bundle/static/images/icon_cashOut_fail.png b/src/bundle/static/images/icon_cashOut_fail.png new file mode 100644 index 0000000..5f63ae4 Binary files /dev/null and b/src/bundle/static/images/icon_cashOut_fail.png differ diff --git a/src/bundle/static/images/icon_cashOut_success.png b/src/bundle/static/images/icon_cashOut_success.png new file mode 100644 index 0000000..0e7e70e Binary files /dev/null and b/src/bundle/static/images/icon_cashOut_success.png differ diff --git a/src/bundle/static/images/icon_cashOut_wait.png b/src/bundle/static/images/icon_cashOut_wait.png new file mode 100644 index 0000000..c602d83 Binary files /dev/null and b/src/bundle/static/images/icon_cashOut_wait.png differ diff --git a/src/bundle/static/images/icon_del.png b/src/bundle/static/images/icon_del.png new file mode 100644 index 0000000..92c4fea Binary files /dev/null and b/src/bundle/static/images/icon_del.png differ diff --git a/src/bundle/static/images/icon_wechat.png b/src/bundle/static/images/icon_wechat.png new file mode 100644 index 0000000..f920b61 Binary files /dev/null and b/src/bundle/static/images/icon_wechat.png differ diff --git a/src/bundle/static/images/mb-like.svg b/src/bundle/static/images/mb-like.svg new file mode 100644 index 0000000..b9d7f26 --- /dev/null +++ b/src/bundle/static/images/mb-like.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/components/app/app.vue b/src/components/app/app.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/components/avatar-upload/avatar-upload.vue b/src/components/avatar-upload/avatar-upload.vue new file mode 100644 index 0000000..497f19d --- /dev/null +++ b/src/components/avatar-upload/avatar-upload.vue @@ -0,0 +1,105 @@ + + + + diff --git a/src/components/cheap-popup/cheap-popup.vue b/src/components/cheap-popup/cheap-popup.vue new file mode 100644 index 0000000..cc48d98 --- /dev/null +++ b/src/components/cheap-popup/cheap-popup.vue @@ -0,0 +1,123 @@ + + + diff --git a/src/components/coupon-card/coupon-card copy 2.vue b/src/components/coupon-card/coupon-card copy 2.vue new file mode 100644 index 0000000..ffeeec7 --- /dev/null +++ b/src/components/coupon-card/coupon-card copy 2.vue @@ -0,0 +1,280 @@ + + + + + \ No newline at end of file diff --git a/src/components/coupon-card/coupon-card copy.vue b/src/components/coupon-card/coupon-card copy.vue new file mode 100644 index 0000000..5466880 --- /dev/null +++ b/src/components/coupon-card/coupon-card copy.vue @@ -0,0 +1,197 @@ + + + + + diff --git a/src/components/coupon-card/coupon-card.vue b/src/components/coupon-card/coupon-card.vue new file mode 100644 index 0000000..1b2d3c4 --- /dev/null +++ b/src/components/coupon-card/coupon-card.vue @@ -0,0 +1,328 @@ + + + + + diff --git a/src/components/goods-card/index.vue b/src/components/goods-card/index.vue new file mode 100644 index 0000000..8248d39 --- /dev/null +++ b/src/components/goods-card/index.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/src/components/goods-desc/index.vue b/src/components/goods-desc/index.vue new file mode 100644 index 0000000..2f8d12e --- /dev/null +++ b/src/components/goods-desc/index.vue @@ -0,0 +1,207 @@ + + + + + diff --git a/src/components/la-swiper/la-swiper.vue b/src/components/la-swiper/la-swiper.vue new file mode 100644 index 0000000..236a71a --- /dev/null +++ b/src/components/la-swiper/la-swiper.vue @@ -0,0 +1,51 @@ + + + + diff --git a/src/components/mplogin-popup/mplogin-popup.vue b/src/components/mplogin-popup/mplogin-popup.vue new file mode 100644 index 0000000..5ff8b10 --- /dev/null +++ b/src/components/mplogin-popup/mplogin-popup.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/src/components/news-card/news-card.vue b/src/components/news-card/news-card.vue new file mode 100644 index 0000000..0e33206 --- /dev/null +++ b/src/components/news-card/news-card.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/components/order-footer/index.vue b/src/components/order-footer/index.vue new file mode 100644 index 0000000..5f01371 --- /dev/null +++ b/src/components/order-footer/index.vue @@ -0,0 +1,598 @@ + + + + + diff --git a/src/components/page-status/page-status.vue b/src/components/page-status/page-status.vue new file mode 100644 index 0000000..946fcc3 --- /dev/null +++ b/src/components/page-status/page-status.vue @@ -0,0 +1,62 @@ + + + + + diff --git a/src/components/payment/component/pay-way-list.vue b/src/components/payment/component/pay-way-list.vue new file mode 100644 index 0000000..45e1121 --- /dev/null +++ b/src/components/payment/component/pay-way-list.vue @@ -0,0 +1,49 @@ + + + diff --git a/src/components/payment/payment.vue b/src/components/payment/payment.vue new file mode 100644 index 0000000..5e6f1ff --- /dev/null +++ b/src/components/payment/payment.vue @@ -0,0 +1,525 @@ + + + + + diff --git a/src/components/price/index.vue b/src/components/price/index.vue new file mode 100644 index 0000000..33a734f --- /dev/null +++ b/src/components/price/index.vue @@ -0,0 +1,38 @@ + + + + + diff --git a/src/components/price/price-v2.vue b/src/components/price/price-v2.vue new file mode 100644 index 0000000..10967ad --- /dev/null +++ b/src/components/price/price-v2.vue @@ -0,0 +1,155 @@ + + + + + diff --git a/src/components/qrcode/index.vue b/src/components/qrcode/index.vue new file mode 100644 index 0000000..af3f321 --- /dev/null +++ b/src/components/qrcode/index.vue @@ -0,0 +1,231 @@ + + + + diff --git a/src/components/qrcode/qrcode.js b/src/components/qrcode/qrcode.js new file mode 100644 index 0000000..6ea6553 --- /dev/null +++ b/src/components/qrcode/qrcode.js @@ -0,0 +1,1201 @@ +let QRCode = {}; +(function () { + /** + * 获取单个字符的utf8编码 + * unicode BMP平面约65535个字符 + * @param {num} code + * return {array} + */ + function unicodeFormat8(code) { + // 1 byte + var c0, c1, c2; + if (code < 128) { + return [code]; + // 2 bytes + } else if (code < 2048) { + c0 = 192 + (code >> 6); + c1 = 128 + (code & 63); + return [c0, c1]; + // 3 bytes + } else { + c0 = 224 + (code >> 12); + c1 = 128 + (code >> 6 & 63); + c2 = 128 + (code & 63); + return [c0, c1, c2]; + } + } + /** + * 获取字符串的utf8编码字节串 + * @param {string} string + * @return {array} + */ + function getUTF8Bytes(string) { + var utf8codes = []; + for (var i = 0; i < string.length; i++) { + var code = string.charCodeAt(i); + var utf8 = unicodeFormat8(code); + for (var j = 0; j < utf8.length; j++) { + utf8codes.push(utf8[j]); + } + } + return utf8codes; + } + /** + * 二维码算法实现 + * @param {string} data 要编码的信息字符串 + * @param {num} errorCorrectLevel 纠错等级 + */ + function QRCodeAlg(data, errorCorrectLevel) { + this.typeNumber = -1; //版本 + this.errorCorrectLevel = errorCorrectLevel; + this.modules = null; //二维矩阵,存放最终结果 + this.moduleCount = 0; //矩阵大小 + this.dataCache = null; //数据缓存 + this.rsBlocks = null; //版本数据信息 + this.totalDataCount = -1; //可使用的数据量 + this.data = data; + this.utf8bytes = getUTF8Bytes(data); + this.make(); + } + QRCodeAlg.prototype = { + constructor: QRCodeAlg, + /** + * 获取二维码矩阵大小 + * @return {num} 矩阵大小 + */ + getModuleCount: function () { + return this.moduleCount; + }, + /** + * 编码 + */ + make: function () { + this.getRightType(); + this.dataCache = this.createData(); + this.createQrcode(); + }, + /** + * 设置二位矩阵功能图形 + * @param {bool} test 表示是否在寻找最好掩膜阶段 + * @param {num} maskPattern 掩膜的版本 + */ + makeImpl: function (maskPattern) { + this.moduleCount = this.typeNumber * 4 + 17; + this.modules = new Array(this.moduleCount); + for (var row = 0; row < this.moduleCount; row++) { + this.modules[row] = new Array(this.moduleCount); + } + this.setupPositionProbePattern(0, 0); + this.setupPositionProbePattern(this.moduleCount - 7, 0); + this.setupPositionProbePattern(0, this.moduleCount - 7); + this.setupPositionAdjustPattern(); + this.setupTimingPattern(); + this.setupTypeInfo(true, maskPattern); + if (this.typeNumber >= 7) { + this.setupTypeNumber(true); + } + this.mapData(this.dataCache, maskPattern); + }, + /** + * 设置二维码的位置探测图形 + * @param {num} row 探测图形的中心横坐标 + * @param {num} col 探测图形的中心纵坐标 + */ + setupPositionProbePattern: function (row, col) { + for (var r = -1; r <= 7; r++) { + if (row + r <= -1 || this.moduleCount <= row + r) continue; + for (var c = -1; c <= 7; c++) { + if (col + c <= -1 || this.moduleCount <= col + c) continue; + if ((0 <= r && r <= 6 && (c == 0 || c == 6)) || (0 <= c && c <= 6 && (r == 0 || r == 6)) || (2 <= r && r <= 4 && 2 <= c && c <= 4)) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + }, + /** + * 创建二维码 + * @return {[type]} [description] + */ + createQrcode: function () { + var minLostPoint = 0; + var pattern = 0; + var bestModules = null; + for (var i = 0; i < 8; i++) { + this.makeImpl(i); + var lostPoint = QRUtil.getLostPoint(this); + if (i == 0 || minLostPoint > lostPoint) { + minLostPoint = lostPoint; + pattern = i; + bestModules = this.modules; + } + } + this.modules = bestModules; + this.setupTypeInfo(false, pattern); + if (this.typeNumber >= 7) { + this.setupTypeNumber(false); + } + }, + /** + * 设置定位图形 + * @return {[type]} [description] + */ + setupTimingPattern: function () { + for (var r = 8; r < this.moduleCount - 8; r++) { + if (this.modules[r][6] != null) { + continue; + } + this.modules[r][6] = (r % 2 == 0); + if (this.modules[6][r] != null) { + continue; + } + this.modules[6][r] = (r % 2 == 0); + } + }, + /** + * 设置矫正图形 + * @return {[type]} [description] + */ + setupPositionAdjustPattern: function () { + var pos = QRUtil.getPatternPosition(this.typeNumber); + for (var i = 0; i < pos.length; i++) { + for (var j = 0; j < pos.length; j++) { + var row = pos[i]; + var col = pos[j]; + if (this.modules[row][col] != null) { + continue; + } + for (var r = -2; r <= 2; r++) { + for (var c = -2; c <= 2; c++) { + if (r == -2 || r == 2 || c == -2 || c == 2 || (r == 0 && c == 0)) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + } + } + }, + /** + * 设置版本信息(7以上版本才有) + * @param {bool} test 是否处于判断最佳掩膜阶段 + * @return {[type]} [description] + */ + setupTypeNumber: function (test) { + var bits = QRUtil.getBCHTypeNumber(this.typeNumber); + for (var i = 0; i < 18; i++) { + var mod = (!test && ((bits >> i) & 1) == 1); + this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod; + this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod; + } + }, + /** + * 设置格式信息(纠错等级和掩膜版本) + * @param {bool} test + * @param {num} maskPattern 掩膜版本 + * @return {} + */ + setupTypeInfo: function (test, maskPattern) { + var data = (QRErrorCorrectLevel[this.errorCorrectLevel] << 3) | maskPattern; + var bits = QRUtil.getBCHTypeInfo(data); + // vertical + for (var i = 0; i < 15; i++) { + var mod = (!test && ((bits >> i) & 1) == 1); + if (i < 6) { + this.modules[i][8] = mod; + } else if (i < 8) { + this.modules[i + 1][8] = mod; + } else { + this.modules[this.moduleCount - 15 + i][8] = mod; + } + // horizontal + var mod = (!test && ((bits >> i) & 1) == 1); + if (i < 8) { + this.modules[8][this.moduleCount - i - 1] = mod; + } else if (i < 9) { + this.modules[8][15 - i - 1 + 1] = mod; + } else { + this.modules[8][15 - i - 1] = mod; + } + } + // fixed module + this.modules[this.moduleCount - 8][8] = (!test); + }, + /** + * 数据编码 + * @return {[type]} [description] + */ + createData: function () { + var buffer = new QRBitBuffer(); + var lengthBits = this.typeNumber > 9 ? 16 : 8; + buffer.put(4, 4); //添加模式 + buffer.put(this.utf8bytes.length, lengthBits); + for (var i = 0, l = this.utf8bytes.length; i < l; i++) { + buffer.put(this.utf8bytes[i], 8); + } + if (buffer.length + 4 <= this.totalDataCount * 8) { + buffer.put(0, 4); + } + // padding + while (buffer.length % 8 != 0) { + buffer.putBit(false); + } + // padding + while (true) { + if (buffer.length >= this.totalDataCount * 8) { + break; + } + buffer.put(QRCodeAlg.PAD0, 8); + if (buffer.length >= this.totalDataCount * 8) { + break; + } + buffer.put(QRCodeAlg.PAD1, 8); + } + return this.createBytes(buffer); + }, + /** + * 纠错码编码 + * @param {buffer} buffer 数据编码 + * @return {[type]} + */ + createBytes: function (buffer) { + var offset = 0; + var maxDcCount = 0; + var maxEcCount = 0; + var length = this.rsBlock.length / 3; + var rsBlocks = new Array(); + for (var i = 0; i < length; i++) { + var count = this.rsBlock[i * 3 + 0]; + var totalCount = this.rsBlock[i * 3 + 1]; + var dataCount = this.rsBlock[i * 3 + 2]; + for (var j = 0; j < count; j++) { + rsBlocks.push([dataCount, totalCount]); + } + } + var dcdata = new Array(rsBlocks.length); + var ecdata = new Array(rsBlocks.length); + for (var r = 0; r < rsBlocks.length; r++) { + var dcCount = rsBlocks[r][0]; + var ecCount = rsBlocks[r][1] - dcCount; + maxDcCount = Math.max(maxDcCount, dcCount); + maxEcCount = Math.max(maxEcCount, ecCount); + dcdata[r] = new Array(dcCount); + for (var i = 0; i < dcdata[r].length; i++) { + dcdata[r][i] = 0xff & buffer.buffer[i + offset]; + } + offset += dcCount; + var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount); + var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1); + var modPoly = rawPoly.mod(rsPoly); + ecdata[r] = new Array(rsPoly.getLength() - 1); + for (var i = 0; i < ecdata[r].length; i++) { + var modIndex = i + modPoly.getLength() - ecdata[r].length; + ecdata[r][i] = (modIndex >= 0) ? modPoly.get(modIndex) : 0; + } + } + var data = new Array(this.totalDataCount); + var index = 0; + for (var i = 0; i < maxDcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < dcdata[r].length) { + data[index++] = dcdata[r][i]; + } + } + } + for (var i = 0; i < maxEcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < ecdata[r].length) { + data[index++] = ecdata[r][i]; + } + } + } + return data; + + }, + /** + * 布置模块,构建最终信息 + * @param {} data + * @param {} maskPattern + * @return {} + */ + mapData: function (data, maskPattern) { + var inc = -1; + var row = this.moduleCount - 1; + var bitIndex = 7; + var byteIndex = 0; + for (var col = this.moduleCount - 1; col > 0; col -= 2) { + if (col == 6) col--; + while (true) { + for (var c = 0; c < 2; c++) { + if (this.modules[row][col - c] == null) { + var dark = false; + if (byteIndex < data.length) { + dark = (((data[byteIndex] >>> bitIndex) & 1) == 1); + } + var mask = QRUtil.getMask(maskPattern, row, col - c); + if (mask) { + dark = !dark; + } + this.modules[row][col - c] = dark; + bitIndex--; + if (bitIndex == -1) { + byteIndex++; + bitIndex = 7; + } + } + } + row += inc; + if (row < 0 || this.moduleCount <= row) { + row -= inc; + inc = -inc; + break; + } + } + } + } + }; + /** + * 填充字段 + */ + QRCodeAlg.PAD0 = 0xEC; + QRCodeAlg.PAD1 = 0x11; + //--------------------------------------------------------------------- + // 纠错等级对应的编码 + //--------------------------------------------------------------------- + var QRErrorCorrectLevel = [1, 0, 3, 2]; + //--------------------------------------------------------------------- + // 掩膜版本 + //--------------------------------------------------------------------- + var QRMaskPattern = { + PATTERN000: 0, + PATTERN001: 1, + PATTERN010: 2, + PATTERN011: 3, + PATTERN100: 4, + PATTERN101: 5, + PATTERN110: 6, + PATTERN111: 7 + }; + //--------------------------------------------------------------------- + // 工具类 + //--------------------------------------------------------------------- + var QRUtil = { + /* + 每个版本矫正图形的位置 + */ + PATTERN_POSITION_TABLE: [ + [], + [6, 18], + [6, 22], + [6, 26], + [6, 30], + [6, 34], + [6, 22, 38], + [6, 24, 42], + [6, 26, 46], + [6, 28, 50], + [6, 30, 54], + [6, 32, 58], + [6, 34, 62], + [6, 26, 46, 66], + [6, 26, 48, 70], + [6, 26, 50, 74], + [6, 30, 54, 78], + [6, 30, 56, 82], + [6, 30, 58, 86], + [6, 34, 62, 90], + [6, 28, 50, 72, 94], + [6, 26, 50, 74, 98], + [6, 30, 54, 78, 102], + [6, 28, 54, 80, 106], + [6, 32, 58, 84, 110], + [6, 30, 58, 86, 114], + [6, 34, 62, 90, 118], + [6, 26, 50, 74, 98, 122], + [6, 30, 54, 78, 102, 126], + [6, 26, 52, 78, 104, 130], + [6, 30, 56, 82, 108, 134], + [6, 34, 60, 86, 112, 138], + [6, 30, 58, 86, 114, 142], + [6, 34, 62, 90, 118, 146], + [6, 30, 54, 78, 102, 126, 150], + [6, 24, 50, 76, 102, 128, 154], + [6, 28, 54, 80, 106, 132, 158], + [6, 32, 58, 84, 110, 136, 162], + [6, 26, 54, 82, 110, 138, 166], + [6, 30, 58, 86, 114, 142, 170] + ], + G15: (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0), + G18: (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0), + G15_MASK: (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1), + /* + BCH编码格式信息 + */ + getBCHTypeInfo: function (data) { + var d = data << 10; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) { + d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15))); + } + return ((data << 10) | d) ^ QRUtil.G15_MASK; + }, + /* + BCH编码版本信息 + */ + getBCHTypeNumber: function (data) { + var d = data << 12; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) { + d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18))); + } + return (data << 12) | d; + }, + /* + 获取BCH位信息 + */ + getBCHDigit: function (data) { + var digit = 0; + while (data != 0) { + digit++; + data >>>= 1; + } + return digit; + }, + /* + 获取版本对应的矫正图形位置 + */ + getPatternPosition: function (typeNumber) { + return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1]; + }, + /* + 掩膜算法 + */ + getMask: function (maskPattern, i, j) { + switch (maskPattern) { + case QRMaskPattern.PATTERN000: + return (i + j) % 2 == 0; + case QRMaskPattern.PATTERN001: + return i % 2 == 0; + case QRMaskPattern.PATTERN010: + return j % 3 == 0; + case QRMaskPattern.PATTERN011: + return (i + j) % 3 == 0; + case QRMaskPattern.PATTERN100: + return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0; + case QRMaskPattern.PATTERN101: + return (i * j) % 2 + (i * j) % 3 == 0; + case QRMaskPattern.PATTERN110: + return ((i * j) % 2 + (i * j) % 3) % 2 == 0; + case QRMaskPattern.PATTERN111: + return ((i * j) % 3 + (i + j) % 2) % 2 == 0; + default: + throw new Error("bad maskPattern:" + maskPattern); + } + }, + /* + 获取RS的纠错多项式 + */ + getErrorCorrectPolynomial: function (errorCorrectLength) { + var a = new QRPolynomial([1], 0); + for (var i = 0; i < errorCorrectLength; i++) { + a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0)); + } + return a; + }, + /* + 获取评价 + */ + getLostPoint: function (qrCode) { + var moduleCount = qrCode.getModuleCount(), + lostPoint = 0, + darkCount = 0; + for (var row = 0; row < moduleCount; row++) { + var sameCount = 0; + var head = qrCode.modules[row][0]; + for (var col = 0; col < moduleCount; col++) { + var current = qrCode.modules[row][col]; + //level 3 评价 + if (col < moduleCount - 6) { + if (current && !qrCode.modules[row][col + 1] && qrCode.modules[row][col + 2] && qrCode.modules[row][col + 3] && qrCode.modules[row][col + 4] && !qrCode.modules[row][col + 5] && qrCode.modules[row][col + 6]) { + if (col < moduleCount - 10) { + if (qrCode.modules[row][col + 7] && qrCode.modules[row][col + 8] && qrCode.modules[row][col + 9] && qrCode.modules[row][col + 10]) { + lostPoint += 40; + } + } else if (col > 3) { + if (qrCode.modules[row][col - 1] && qrCode.modules[row][col - 2] && qrCode.modules[row][col - 3] && qrCode.modules[row][col - 4]) { + lostPoint += 40; + } + } + } + } + //level 2 评价 + if ((row < moduleCount - 1) && (col < moduleCount - 1)) { + var count = 0; + if (current) count++; + if (qrCode.modules[row + 1][col]) count++; + if (qrCode.modules[row][col + 1]) count++; + if (qrCode.modules[row + 1][col + 1]) count++; + if (count == 0 || count == 4) { + lostPoint += 3; + } + } + //level 1 评价 + if (head ^ current) { + sameCount++; + } else { + head = current; + if (sameCount >= 5) { + lostPoint += (3 + sameCount - 5); + } + sameCount = 1; + } + //level 4 评价 + if (current) { + darkCount++; + } + } + } + for (var col = 0; col < moduleCount; col++) { + var sameCount = 0; + var head = qrCode.modules[0][col]; + for (var row = 0; row < moduleCount; row++) { + var current = qrCode.modules[row][col]; + //level 3 评价 + if (row < moduleCount - 6) { + if (current && !qrCode.modules[row + 1][col] && qrCode.modules[row + 2][col] && qrCode.modules[row + 3][col] && qrCode.modules[row + 4][col] && !qrCode.modules[row + 5][col] && qrCode.modules[row + 6][col]) { + if (row < moduleCount - 10) { + if (qrCode.modules[row + 7][col] && qrCode.modules[row + 8][col] && qrCode.modules[row + 9][col] && qrCode.modules[row + 10][col]) { + lostPoint += 40; + } + } else if (row > 3) { + if (qrCode.modules[row - 1][col] && qrCode.modules[row - 2][col] && qrCode.modules[row - 3][col] && qrCode.modules[row - 4][col]) { + lostPoint += 40; + } + } + } + } + //level 1 评价 + if (head ^ current) { + sameCount++; + } else { + head = current; + if (sameCount >= 5) { + lostPoint += (3 + sameCount - 5); + } + sameCount = 1; + } + } + } + // LEVEL4 + var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5; + lostPoint += ratio * 10; + return lostPoint; + } + + }; + //--------------------------------------------------------------------- + // QRMath使用的数学工具 + //--------------------------------------------------------------------- + var QRMath = { + /* + 将n转化为a^m + */ + glog: function (n) { + if (n < 1) { + throw new Error("glog(" + n + ")"); + } + return QRMath.LOG_TABLE[n]; + }, + /* + 将a^m转化为n + */ + gexp: function (n) { + while (n < 0) { + n += 255; + } + while (n >= 256) { + n -= 255; + } + return QRMath.EXP_TABLE[n]; + }, + EXP_TABLE: new Array(256), + LOG_TABLE: new Array(256) + + }; + for (var i = 0; i < 8; i++) { + QRMath.EXP_TABLE[i] = 1 << i; + } + for (var i = 8; i < 256; i++) { + QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8]; + } + for (var i = 0; i < 255; i++) { + QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i; + } + //--------------------------------------------------------------------- + // QRPolynomial 多项式 + //--------------------------------------------------------------------- + /** + * 多项式类 + * @param {Array} num 系数 + * @param {num} shift a^shift + */ + function QRPolynomial(num, shift) { + if (num.length == undefined) { + throw new Error(num.length + "/" + shift); + } + var offset = 0; + while (offset < num.length && num[offset] == 0) { + offset++; + } + this.num = new Array(num.length - offset + shift); + for (var i = 0; i < num.length - offset; i++) { + this.num[i] = num[i + offset]; + } + } + QRPolynomial.prototype = { + get: function (index) { + return this.num[index]; + }, + getLength: function () { + return this.num.length; + }, + /** + * 多项式乘法 + * @param {QRPolynomial} e 被乘多项式 + * @return {[type]} [description] + */ + multiply: function (e) { + var num = new Array(this.getLength() + e.getLength() - 1); + for (var i = 0; i < this.getLength(); i++) { + for (var j = 0; j < e.getLength(); j++) { + num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j))); + } + } + return new QRPolynomial(num, 0); + }, + /** + * 多项式模运算 + * @param {QRPolynomial} e 模多项式 + * @return {} + */ + mod: function (e) { + var tl = this.getLength(), + el = e.getLength(); + if (tl - el < 0) { + return this; + } + var num = new Array(tl); + for (var i = 0; i < tl; i++) { + num[i] = this.get(i); + } + while (num.length >= el) { + var ratio = QRMath.glog(num[0]) - QRMath.glog(e.get(0)); + + for (var i = 0; i < e.getLength(); i++) { + num[i] ^= QRMath.gexp(QRMath.glog(e.get(i)) + ratio); + } + while (num[0] == 0) { + num.shift(); + } + } + return new QRPolynomial(num, 0); + } + }; + + //--------------------------------------------------------------------- + // RS_BLOCK_TABLE + //--------------------------------------------------------------------- + /* + 二维码各个版本信息[块数, 每块中的数据块数, 每块中的信息块数] + */ + var RS_BLOCK_TABLE = [ + // L + // M + // Q + // H + // 1 + [1, 26, 19], + [1, 26, 16], + [1, 26, 13], + [1, 26, 9], + + // 2 + [1, 44, 34], + [1, 44, 28], + [1, 44, 22], + [1, 44, 16], + + // 3 + [1, 70, 55], + [1, 70, 44], + [2, 35, 17], + [2, 35, 13], + + // 4 + [1, 100, 80], + [2, 50, 32], + [2, 50, 24], + [4, 25, 9], + + // 5 + [1, 134, 108], + [2, 67, 43], + [2, 33, 15, 2, 34, 16], + [2, 33, 11, 2, 34, 12], + + // 6 + [2, 86, 68], + [4, 43, 27], + [4, 43, 19], + [4, 43, 15], + + // 7 + [2, 98, 78], + [4, 49, 31], + [2, 32, 14, 4, 33, 15], + [4, 39, 13, 1, 40, 14], + + // 8 + [2, 121, 97], + [2, 60, 38, 2, 61, 39], + [4, 40, 18, 2, 41, 19], + [4, 40, 14, 2, 41, 15], + + // 9 + [2, 146, 116], + [3, 58, 36, 2, 59, 37], + [4, 36, 16, 4, 37, 17], + [4, 36, 12, 4, 37, 13], + + // 10 + [2, 86, 68, 2, 87, 69], + [4, 69, 43, 1, 70, 44], + [6, 43, 19, 2, 44, 20], + [6, 43, 15, 2, 44, 16], + + // 11 + [4, 101, 81], + [1, 80, 50, 4, 81, 51], + [4, 50, 22, 4, 51, 23], + [3, 36, 12, 8, 37, 13], + + // 12 + [2, 116, 92, 2, 117, 93], + [6, 58, 36, 2, 59, 37], + [4, 46, 20, 6, 47, 21], + [7, 42, 14, 4, 43, 15], + + // 13 + [4, 133, 107], + [8, 59, 37, 1, 60, 38], + [8, 44, 20, 4, 45, 21], + [12, 33, 11, 4, 34, 12], + + // 14 + [3, 145, 115, 1, 146, 116], + [4, 64, 40, 5, 65, 41], + [11, 36, 16, 5, 37, 17], + [11, 36, 12, 5, 37, 13], + + // 15 + [5, 109, 87, 1, 110, 88], + [5, 65, 41, 5, 66, 42], + [5, 54, 24, 7, 55, 25], + [11, 36, 12], + + // 16 + [5, 122, 98, 1, 123, 99], + [7, 73, 45, 3, 74, 46], + [15, 43, 19, 2, 44, 20], + [3, 45, 15, 13, 46, 16], + + // 17 + [1, 135, 107, 5, 136, 108], + [10, 74, 46, 1, 75, 47], + [1, 50, 22, 15, 51, 23], + [2, 42, 14, 17, 43, 15], + + // 18 + [5, 150, 120, 1, 151, 121], + [9, 69, 43, 4, 70, 44], + [17, 50, 22, 1, 51, 23], + [2, 42, 14, 19, 43, 15], + + // 19 + [3, 141, 113, 4, 142, 114], + [3, 70, 44, 11, 71, 45], + [17, 47, 21, 4, 48, 22], + [9, 39, 13, 16, 40, 14], + + // 20 + [3, 135, 107, 5, 136, 108], + [3, 67, 41, 13, 68, 42], + [15, 54, 24, 5, 55, 25], + [15, 43, 15, 10, 44, 16], + + // 21 + [4, 144, 116, 4, 145, 117], + [17, 68, 42], + [17, 50, 22, 6, 51, 23], + [19, 46, 16, 6, 47, 17], + + // 22 + [2, 139, 111, 7, 140, 112], + [17, 74, 46], + [7, 54, 24, 16, 55, 25], + [34, 37, 13], + + // 23 + [4, 151, 121, 5, 152, 122], + [4, 75, 47, 14, 76, 48], + [11, 54, 24, 14, 55, 25], + [16, 45, 15, 14, 46, 16], + + // 24 + [6, 147, 117, 4, 148, 118], + [6, 73, 45, 14, 74, 46], + [11, 54, 24, 16, 55, 25], + [30, 46, 16, 2, 47, 17], + + // 25 + [8, 132, 106, 4, 133, 107], + [8, 75, 47, 13, 76, 48], + [7, 54, 24, 22, 55, 25], + [22, 45, 15, 13, 46, 16], + + // 26 + [10, 142, 114, 2, 143, 115], + [19, 74, 46, 4, 75, 47], + [28, 50, 22, 6, 51, 23], + [33, 46, 16, 4, 47, 17], + + // 27 + [8, 152, 122, 4, 153, 123], + [22, 73, 45, 3, 74, 46], + [8, 53, 23, 26, 54, 24], + [12, 45, 15, 28, 46, 16], + + // 28 + [3, 147, 117, 10, 148, 118], + [3, 73, 45, 23, 74, 46], + [4, 54, 24, 31, 55, 25], + [11, 45, 15, 31, 46, 16], + + // 29 + [7, 146, 116, 7, 147, 117], + [21, 73, 45, 7, 74, 46], + [1, 53, 23, 37, 54, 24], + [19, 45, 15, 26, 46, 16], + + // 30 + [5, 145, 115, 10, 146, 116], + [19, 75, 47, 10, 76, 48], + [15, 54, 24, 25, 55, 25], + [23, 45, 15, 25, 46, 16], + + // 31 + [13, 145, 115, 3, 146, 116], + [2, 74, 46, 29, 75, 47], + [42, 54, 24, 1, 55, 25], + [23, 45, 15, 28, 46, 16], + + // 32 + [17, 145, 115], + [10, 74, 46, 23, 75, 47], + [10, 54, 24, 35, 55, 25], + [19, 45, 15, 35, 46, 16], + + // 33 + [17, 145, 115, 1, 146, 116], + [14, 74, 46, 21, 75, 47], + [29, 54, 24, 19, 55, 25], + [11, 45, 15, 46, 46, 16], + + // 34 + [13, 145, 115, 6, 146, 116], + [14, 74, 46, 23, 75, 47], + [44, 54, 24, 7, 55, 25], + [59, 46, 16, 1, 47, 17], + + // 35 + [12, 151, 121, 7, 152, 122], + [12, 75, 47, 26, 76, 48], + [39, 54, 24, 14, 55, 25], + [22, 45, 15, 41, 46, 16], + + // 36 + [6, 151, 121, 14, 152, 122], + [6, 75, 47, 34, 76, 48], + [46, 54, 24, 10, 55, 25], + [2, 45, 15, 64, 46, 16], + + // 37 + [17, 152, 122, 4, 153, 123], + [29, 74, 46, 14, 75, 47], + [49, 54, 24, 10, 55, 25], + [24, 45, 15, 46, 46, 16], + + // 38 + [4, 152, 122, 18, 153, 123], + [13, 74, 46, 32, 75, 47], + [48, 54, 24, 14, 55, 25], + [42, 45, 15, 32, 46, 16], + + // 39 + [20, 147, 117, 4, 148, 118], + [40, 75, 47, 7, 76, 48], + [43, 54, 24, 22, 55, 25], + [10, 45, 15, 67, 46, 16], + + // 40 + [19, 148, 118, 6, 149, 119], + [18, 75, 47, 31, 76, 48], + [34, 54, 24, 34, 55, 25], + [20, 45, 15, 61, 46, 16] + ]; + + /** + * 根据数据获取对应版本 + * @return {[type]} [description] + */ + QRCodeAlg.prototype.getRightType = function () { + for (var typeNumber = 1; typeNumber < 41; typeNumber++) { + var rsBlock = RS_BLOCK_TABLE[(typeNumber - 1) * 4 + this.errorCorrectLevel]; + if (rsBlock == undefined) { + throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + this.errorCorrectLevel); + } + var length = rsBlock.length / 3; + var totalDataCount = 0; + for (var i = 0; i < length; i++) { + var count = rsBlock[i * 3 + 0]; + var dataCount = rsBlock[i * 3 + 2]; + totalDataCount += dataCount * count; + } + var lengthBytes = typeNumber > 9 ? 2 : 1; + if (this.utf8bytes.length + lengthBytes < totalDataCount || typeNumber == 40) { + this.typeNumber = typeNumber; + this.rsBlock = rsBlock; + this.totalDataCount = totalDataCount; + break; + } + } + }; + + //--------------------------------------------------------------------- + // QRBitBuffer + //--------------------------------------------------------------------- + function QRBitBuffer() { + this.buffer = new Array(); + this.length = 0; + } + QRBitBuffer.prototype = { + get: function (index) { + var bufIndex = Math.floor(index / 8); + return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1); + }, + put: function (num, length) { + for (var i = 0; i < length; i++) { + this.putBit(((num >>> (length - i - 1)) & 1)); + } + }, + putBit: function (bit) { + var bufIndex = Math.floor(this.length / 8); + if (this.buffer.length <= bufIndex) { + this.buffer.push(0); + } + if (bit) { + this.buffer[bufIndex] |= (0x80 >>> (this.length % 8)); + } + this.length++; + } + }; + + + + // xzedit + let qrcodeAlgObjCache = []; + /** + * 二维码构造函数,主要用于绘制 + * @param {参数列表} opt 传递参数 + * @return {} + */ + QRCode = function (opt) { + //设置默认参数 + this.options = { + text: '', + size: 256, + correctLevel: 3, + background: '#ffffff', + foreground: '#000000', + pdground: '#000000', + image: '', + imageSize: 30, + canvasId: opt.canvasId, + context: opt.context, + usingComponents: opt.usingComponents, + showLoading: opt.showLoading, + loadingText: opt.loadingText, + }; + if (typeof opt === 'string') { // 只编码ASCII字符串 + opt = { + text: opt + }; + } + if (opt) { + for (var i in opt) { + this.options[i] = opt[i]; + } + } + //使用QRCodeAlg创建二维码结构 + var qrCodeAlg = null; + for (var i = 0, l = qrcodeAlgObjCache.length; i < l; i++) { + if (qrcodeAlgObjCache[i].text == this.options.text && qrcodeAlgObjCache[i].text.correctLevel == this.options.correctLevel) { + qrCodeAlg = qrcodeAlgObjCache[i].obj; + break; + } + } + if (i == l) { + qrCodeAlg = new QRCodeAlg(this.options.text, this.options.correctLevel); + qrcodeAlgObjCache.push({ + text: this.options.text, + correctLevel: this.options.correctLevel, + obj: qrCodeAlg + }); + } + /** + * 计算矩阵点的前景色 + * @param {Obj} config + * @param {Number} config.row 点x坐标 + * @param {Number} config.col 点y坐标 + * @param {Number} config.count 矩阵大小 + * @param {Number} config.options 组件的options + * @return {String} + */ + let getForeGround = function (config) { + var options = config.options; + if (options.pdground && ( + (config.row > 1 && config.row < 5 && config.col > 1 && config.col < 5) || + (config.row > (config.count - 6) && config.row < (config.count - 2) && config.col > 1 && config.col < 5) || + (config.row > 1 && config.row < 5 && config.col > (config.count - 6) && config.col < (config.count - 2)) + )) { + return options.pdground; + } + return options.foreground; + } + // 创建canvas + let createCanvas = function (options) { + if (options.showLoading) { + uni.showLoading({ + title: options.loadingText, + mask: true + }); + } + var ctx = uni.createCanvasContext(options.canvasId, options.context); + var count = qrCodeAlg.getModuleCount(); + var ratioSize = options.size; + var ratioImgSize = options.imageSize; + //计算每个点的长宽 + var tileW = (ratioSize / count).toPrecision(4); + var tileH = (ratioSize / count).toPrecision(4); + //绘制 + for (var row = 0; row < count; row++) { + for (var col = 0; col < count; col++) { + var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW)); + var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW)); + var foreground = getForeGround({ + row: row, + col: col, + count: count, + options: options + }); + ctx.setFillStyle(qrCodeAlg.modules[row][col] ? foreground : options.background); + ctx.fillRect(Math.round(col * tileW), Math.round(row * tileH), w, h); + } + } + if (options.image) { + var x = Number(((ratioSize - ratioImgSize) / 2).toFixed(2)); + var y = Number(((ratioSize - ratioImgSize) / 2).toFixed(2)); + drawRoundedRect(ctx, x, y, ratioImgSize, ratioImgSize, 2, 6, true, true) + ctx.drawImage(options.image, x, y, ratioImgSize, ratioImgSize); + // 画圆角矩形 + function drawRoundedRect(ctxi, x, y, width, height, r, lineWidth, fill, stroke) { + ctxi.setLineWidth(lineWidth); + ctxi.setFillStyle(options.background); + ctxi.setStrokeStyle(options.background); + ctxi.beginPath(); // draw top and top right corner + ctxi.moveTo(x + r, y); + ctxi.arcTo(x + width, y, x + width, y + r, r); // draw right side and bottom right corner + ctxi.arcTo(x + width, y + height, x + width - r, y + height, r); // draw bottom and bottom left corner + ctxi.arcTo(x, y + height, x, y + height - r, r); // draw left and top left corner + ctxi.arcTo(x, y, x + r, y, r); + ctxi.closePath(); + if (fill) { + ctxi.fill(); + } + if (stroke) { + ctxi.stroke(); + } + } + } + setTimeout(() => { + ctx.draw(true, () => { + // 保存到临时区域 + setTimeout(() => { + uni.canvasToTempFilePath({ + width: options.width, + height: options.height, + destWidth: options.width, + destHeight: options.height, + canvasId: options.canvasId, + quality: Number(1), + success: function (res) { + if (options.cbResult) { + options.cbResult(res.tempFilePath) + } + }, + fail: function (res) { + if (options.cbResult) { + options.cbResult(res) + } + }, + complete: function () { + if (options.showLoading){ + uni.hideLoading(); + } + }, + }, options.context); + }, options.text.length + 100); + }); + }, options.usingComponents ? 0 : 150); + } + createCanvas(this.options); + // 空判定 + let empty = function (v) { + let tp = typeof v, + rt = false; + if (tp == "number" && String(v) == "") { + rt = true + } else if (tp == "undefined") { + rt = true + } else if (tp == "object") { + if (JSON.stringify(v) == "{}" || JSON.stringify(v) == "[]" || v == null) rt = true + } else if (tp == "string") { + if (v == "" || v == "undefined" || v == "null" || v == "{}" || v == "[]") rt = true + } else if (tp == "function") { + rt = false + } + return rt + } + }; + QRCode.prototype.clear = function (fn) { + var ctx = uni.createCanvasContext(this.options.canvasId, this.options.context) + ctx.clearRect(0, 0, this.options.size, this.options.size) + ctx.draw(false, () => { + if (fn) { + fn() + } + }) + }; +})() + +export default QRCode \ No newline at end of file diff --git a/src/components/tab/tab.vue b/src/components/tab/tab.vue new file mode 100644 index 0000000..78f1965 --- /dev/null +++ b/src/components/tab/tab.vue @@ -0,0 +1,85 @@ + + + + diff --git a/src/components/tabbar/tabbar.vue b/src/components/tabbar/tabbar.vue new file mode 100644 index 0000000..4aded19 --- /dev/null +++ b/src/components/tabbar/tabbar.vue @@ -0,0 +1,70 @@ + + + diff --git a/src/components/tabs/tabs.vue b/src/components/tabs/tabs.vue new file mode 100644 index 0000000..5a1fae5 --- /dev/null +++ b/src/components/tabs/tabs.vue @@ -0,0 +1,426 @@ + + + + + diff --git a/src/components/uploader/index.vue b/src/components/uploader/index.vue new file mode 100644 index 0000000..46e687a --- /dev/null +++ b/src/components/uploader/index.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/src/components/widgets/banner/banner.vue b/src/components/widgets/banner/banner.vue new file mode 100644 index 0000000..e678153 --- /dev/null +++ b/src/components/widgets/banner/banner.vue @@ -0,0 +1,88 @@ + + + + + + diff --git a/src/components/widgets/category/category.vue b/src/components/widgets/category/category.vue new file mode 100644 index 0000000..76b49f4 --- /dev/null +++ b/src/components/widgets/category/category.vue @@ -0,0 +1,63 @@ + + + + + + diff --git a/src/components/widgets/customer-service/customer-service.vue b/src/components/widgets/customer-service/customer-service.vue new file mode 100644 index 0000000..8cb2fa4 --- /dev/null +++ b/src/components/widgets/customer-service/customer-service.vue @@ -0,0 +1,56 @@ + + + + diff --git a/src/components/widgets/my-service/components/customer-service.vue b/src/components/widgets/my-service/components/customer-service.vue new file mode 100644 index 0000000..13d9828 --- /dev/null +++ b/src/components/widgets/my-service/components/customer-service.vue @@ -0,0 +1,131 @@ + + + + diff --git a/src/components/widgets/my-service/my-service.vue b/src/components/widgets/my-service/my-service.vue new file mode 100644 index 0000000..cc9192c --- /dev/null +++ b/src/components/widgets/my-service/my-service.vue @@ -0,0 +1,92 @@ + + + + + diff --git a/src/components/widgets/my-subscribe/my-subscribe.vue b/src/components/widgets/my-subscribe/my-subscribe.vue new file mode 100644 index 0000000..1cdac33 --- /dev/null +++ b/src/components/widgets/my-subscribe/my-subscribe.vue @@ -0,0 +1,98 @@ + + + + + diff --git a/src/components/widgets/my-task/my-task.vue b/src/components/widgets/my-task/my-task.vue new file mode 100644 index 0000000..f093f5c --- /dev/null +++ b/src/components/widgets/my-task/my-task.vue @@ -0,0 +1,97 @@ + + + + diff --git a/src/components/widgets/nav/nav.vue b/src/components/widgets/nav/nav.vue new file mode 100644 index 0000000..da37c4c --- /dev/null +++ b/src/components/widgets/nav/nav.vue @@ -0,0 +1,46 @@ + + + + + + diff --git a/src/components/widgets/search/search.backup.vue b/src/components/widgets/search/search.backup.vue new file mode 100644 index 0000000..5eaba91 --- /dev/null +++ b/src/components/widgets/search/search.backup.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/src/components/widgets/search/search.vue b/src/components/widgets/search/search.vue new file mode 100644 index 0000000..9a351e5 --- /dev/null +++ b/src/components/widgets/search/search.vue @@ -0,0 +1,101 @@ + + + + + + diff --git a/src/components/widgets/user-banner/user-banner.vue b/src/components/widgets/user-banner/user-banner.vue new file mode 100644 index 0000000..a2bf649 --- /dev/null +++ b/src/components/widgets/user-banner/user-banner.vue @@ -0,0 +1,58 @@ + + + + + + diff --git a/src/components/widgets/user-info/user-info.vue b/src/components/widgets/user-info/user-info.vue new file mode 100644 index 0000000..f376c59 --- /dev/null +++ b/src/components/widgets/user-info/user-info.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/config/app.ts b/src/config/app.ts new file mode 100644 index 0000000..7d7fc23 --- /dev/null +++ b/src/config/app.ts @@ -0,0 +1,4 @@ +// terminal +export const terminal = 1 +// 版本 +export const version = '1.0.0' diff --git a/src/config/index.ts b/src/config/index.ts new file mode 100644 index 0000000..311bbe9 --- /dev/null +++ b/src/config/index.ts @@ -0,0 +1,20 @@ +export const headerOptions = { + urlPrefix: 'api' +} + +export const optionMap = { + couponStatus: [ + { + name: '未使用', + status: 1 + }, + { + name: '已使用', + status: 2 + }, + { + name: '已过期', + status: 3 + } + ] +} \ No newline at end of file diff --git a/src/config/interface.ts b/src/config/interface.ts new file mode 100644 index 0000000..17384d7 --- /dev/null +++ b/src/config/interface.ts @@ -0,0 +1,8 @@ +import { EnumMap } from "enumtor" + +export interface CouponTableProps { + initParams?: any //参数 + requestApi?: (params: any) => Promise //请求api +} + +export type Recordable = Record \ No newline at end of file diff --git a/src/config/symbol.ts b/src/config/symbol.ts new file mode 100644 index 0000000..e032a4b --- /dev/null +++ b/src/config/symbol.ts @@ -0,0 +1,6 @@ +import { InjectionKey, Ref } from "vue"; + +interface CouponContext { + tabStatus: Ref +} +export const COUPON_INJECTION_KEY: InjectionKey = Symbol() \ No newline at end of file diff --git a/src/enums/agreementEnums.ts b/src/enums/agreementEnums.ts new file mode 100644 index 0000000..7a717f4 --- /dev/null +++ b/src/enums/agreementEnums.ts @@ -0,0 +1,5 @@ +//菜单主题类型 +export enum AgreementEnum { + PRIVACY = 'privacy', + SERVICE = 'service' +} diff --git a/src/enums/appEnums.ts b/src/enums/appEnums.ts new file mode 100644 index 0000000..b544125 --- /dev/null +++ b/src/enums/appEnums.ts @@ -0,0 +1,148 @@ +import { Recordable } from '@/config/interface' + +//菜单主题类型 +export enum ThemeEnum { + LIGHT = 'light', + DARK = 'dark' +} + +// 客户端 +export enum ClientEnum { + MP_WEIXIN = 1, // 微信-小程序 + OA_WEIXIN = 2, // 微信-公众号 + H5 = 3, // H5 + IOS = 5, //苹果 + ANDROID = 6, //安卓 + MP_DOUYIN = 7 //抖音 +} + +export enum SMSEnum { + LOGIN = 101, + BIND_MOBILE = 102, + CHANGE_MOBILE = 103, + FIND_PASSWORD = 104 +} + +export enum SearchTypeEnum { + HISTORY = 'history' +} + +// 用户资料 +export enum FieldType { + NONE = '', + AVATAR = 'avatar', + USERNAME = 'username', + NICKNAME = 'nickname', + SEX = 'sex', + defalutNickname = '粤好生活会员' +} + +// 支付页面 +export const PayEnum = { + '1': 'orderBuy', // 确认下单支付 + '2': 'orderList', // 订单列表支付 + '3': 'orderDetail' // 订单详情支付 +} + +// 支付结果 +export enum PayStatusEnum { + SUCCESS = 'success', + FAIL = 'fail', + PENDING = 'pending' +} + +// 页面状态 +export enum PageStatusEnum { + LOADING = 'loading', // 加载中 + NORMAL = 'normal', // 正常 + ERROR = 'error', // 异常 + EMPTY = 'empty' // 为空 +} + +// 支付来源类型 +export enum PayFromType { + ORDER = 'order', + USERRECHARGE = 'user_recharge' +} + +// 支付方式类型 +export enum PayWayType { + WALLET = 1, + WECHAT = 2, + ALIPAY = 3 +} +export enum WithDrawEnum { + PEDDING = 0, + SUCCESS = 1 +} +export const withDrawMap: Recordable = { + [WithDrawEnum.PEDDING]: '申请中', + [WithDrawEnum.SUCCESS]: '提现成功' +} + +export enum CouponEnum { + NO_GET = 0, //未领取 + NO_APPLY = 1, //未使用 + ALIPAY = 2, //已使用 + OVERDUE = 3 //已过期 +} +export enum UseGoodsTypeEnum { + ALL = 1, //通用券 + CATEGORY = 2, //品类券 + CATEGOYR_PART = 3 //商品券 +} +export enum CouponStatusEnum { + AVALIABLE = 1, + UN_AVALIABLE = 2 +} +export enum UseConditionEnum { + NO_CONDITION = 1, //无使用门槛 + CONDITION = 2 //有使用门槛 +} +export enum OrderStatusEnum { + NO_PAYMENT = 0, //未支付 + PAYMENNT = 1 //已支付 +} +export const CouponStatusMap: Recordable = { + [CouponEnum.ALIPAY]: '已使用', + [CouponEnum.OVERDUE]: '已过期' +} + +export const NavigateMap: Recordable = { + [UseGoodsTypeEnum.ALL]: '/pages/index/index', + [UseGoodsTypeEnum.CATEGORY]: '/bundle/pages/category_goods_coupon/goods_category', + [UseGoodsTypeEnum.CATEGOYR_PART]: '/bundle/pages/category_goods_coupon/goods' +} + +export const CouponCountMap: Recordable = { + availableCount: '可用优惠券', + notAvailableCount: '不可用优惠券' +} +export const useGoodsTypeMap: Recordable = { + [UseGoodsTypeEnum.ALL]: '所有', + [UseGoodsTypeEnum.CATEGORY]: '相应品类', + [UseGoodsTypeEnum.CATEGOYR_PART]: '相应商品' +} +export const conditions = [ + { useGoodsType: UseGoodsTypeEnum.ALL, conditionType: UseConditionEnum.NO_CONDITION }, + { useGoodsType: UseGoodsTypeEnum.ALL, conditionType: UseConditionEnum.CONDITION }, + { useGoodsType: UseGoodsTypeEnum.CATEGORY, conditionType: UseConditionEnum.NO_CONDITION }, + { useGoodsType: UseGoodsTypeEnum.CATEGORY, conditionType: UseConditionEnum.CONDITION }, + { useGoodsType: UseGoodsTypeEnum.CATEGOYR_PART, conditionType: UseConditionEnum.NO_CONDITION }, + { useGoodsType: UseGoodsTypeEnum.CATEGOYR_PART, conditionType: UseConditionEnum.CONDITION } +] + +// 多少天即将过期时,在优惠券右上方显示“快失效”字样,默认3天 +export const showExpiringSoonDays = 3 + +// 提现状态 +export enum WithdrawStatusEnum { + WITHDRAWING = 0, + SUCCESS = 1, + FAIL = 2 +} +export const WithdrawStatusMap: Recordable = { + [WithdrawStatusEnum.WITHDRAWING]: '提现中', + [WithdrawStatusEnum.SUCCESS]: '提现成功', + [WithdrawStatusEnum.FAIL]: '提现失败' +} diff --git a/src/enums/cacheEnums.ts b/src/enums/cacheEnums.ts new file mode 100644 index 0000000..59e1645 --- /dev/null +++ b/src/enums/cacheEnums.ts @@ -0,0 +1,13 @@ +// 本地缓冲key + +//token +export const TOKEN_KEY = 'token' + +// 搜索历史记录 +export const HISTORY = 'history' + +export const BACK_URL = 'back_url' + +export const USER_INFO = 'user_info' + +export const DIST_ID = 'dist_id' \ No newline at end of file diff --git a/src/enums/requestEnums.ts b/src/enums/requestEnums.ts new file mode 100644 index 0000000..67d30b2 --- /dev/null +++ b/src/enums/requestEnums.ts @@ -0,0 +1,28 @@ +export enum ContentTypeEnum { + // json + JSON = 'application/json;charset=UTF-8', + // form-data 上传资源(图片,视频) + FORM_DATA = 'multipart/form-data;charset=UTF-8' +} + +export enum RequestMethodsEnum { + GET = 'GET', + POST = 'POST' +} + +export enum RequestCodeEnum { + SUCCESS = 200, //成功 + FAILED = 300, // 失败 + PARAMS_VALID_ERROR = 310, //参数校验错误 + PARAMS_TYPE_ERROR = 311, //参数类型错误 + REQUEST_METHOD_ERROR = 312, //请求方法错误 + ASSERT_ARGUMENT_ERROR = 313, //断言参数错误 + ASSERT_MYBATIS_ERROR = 314, //断言mybatis错误 + LOGIN_ACCOUNT_ERROR = 330, //登陆账号或密码错误 + LOGIN_DISABLE_ERROR = 331, //登陆账号已被禁用 + TOKEN_EMPTY = 332, // TOKEN参数为空 + TOKEN_INVALID = 333, // TOKEN参数无效 + NO_PERMISSTION = 403, //无相关权限 + REQUEST_404_ERROR = 404, //请求接口不存在 + SYSTEM_ERROR = 500 //系统错误 +} diff --git a/src/hooks/payment.ts b/src/hooks/payment.ts new file mode 100644 index 0000000..42b8834 --- /dev/null +++ b/src/hooks/payment.ts @@ -0,0 +1,115 @@ +import { apiPayPrepay, apiQueryOrder, apiH5PayPrepay } from '@/api/app' +import { wxOaPay } from '@/hooks/wechat' +import { wxpay, ttpay, alipay } from '@/utils/pay' +import { getClient } from '@/utils/client' +import { PayEnum } from '../enums/appEnums' +import { ref } from 'vue' + +/** + * @description 支付函数钩子 + * @param { typeValue } 支付的枚举 + * @param { emit } 是否刷新页面 + * @return { Function } 暴露钩子 + */ +export function usePay(typeValue: any, emit: any = () => {}) { + // 支付枚举来源 + const form = ref(PayEnum[typeValue]) + // 订单ID + const order_id = ref(0) + + /** + * @description 1. 初始化获取支付方式 + * @param { params } 支付订单数据 + */ + const initPayWay = async (orderId, orderSn): Promise => { + try { + console.log('orderId:', orderId, orderSn) + order_id.value = orderId + handlePayPrepay(orderId) + } catch (err) { + console.log('获取支付方式', err) + uni.$u.toast('支付方式' + err) + } + } + + /** + * @description 2. 预支付 + * @param { params } 支付订单数据 + */ + const handlePayPrepay = async (orderId): Promise => { + const scene = getClient() + let payChannel = '' + switch (scene) { + case 1: + payChannel = 'mp_channel' + break + case 2: + payChannel = 'oa_channel' + break + case 3: + payChannel = 'h5_channel' + break + } + try { + if (payChannel === 'mp_channel' || payChannel === 'oa_channel') { + const res = await apiPayPrepay({ + orderId, + payChannel + }) + console.log('预支付', res) + // 支付 + handlePay(res) + } else if (payChannel === 'h5_channel') { + const res = await apiH5PayPrepay({ + orderId, + payChannel + }) + console.log('h5预支付', res) + // 支付 + handlePay(res) + } + } catch (err) { + console.log('获取预支付', err) + uni.$u.toast('预支付' + err) + } + } + + /** + * @description 3. 吊起支付并处理支付结构 + * @param { params } 支付订单数据 + */ + const handlePay = async (params): Promise => { + try { + // #ifndef H5 + await wxpay(params) + // #endif + + // #ifdef H5 + console.log('支付前') + await wxOaPay(params) + console.log('支付返回') + // #endif + + // 只在结算订单界面跳转 + // 查询订单状态 + await apiQueryOrder({ id: order_id.value }) + if (form.value === 'orderBuy') uni.reLaunch({ url: `/pages/order/index` }) + else emit('refresh') // 订单列表与详情的情况下刷新 + } catch (err) { + if (form.value === 'orderBuy') { + uni.reLaunch({ url: `/pages/order/index` }) + } + if (Number(mount) == 0) { + return uni.$u.toast('下单成功') + } + uni.$u.toast('支付取消') + console.log(err, '支付取消') + } + } + + return { + initPayWay, + handlePayPrepay, + handlePay + } +} diff --git a/src/hooks/useCopy.ts b/src/hooks/useCopy.ts new file mode 100644 index 0000000..b3571eb --- /dev/null +++ b/src/hooks/useCopy.ts @@ -0,0 +1,10 @@ +export function useCopy() { + const copy = (text: string) => { + uni.setClipboardData({ + data: String(text) + }) + } + return { + copy + } +} diff --git a/src/hooks/useCoupon.ts b/src/hooks/useCoupon.ts new file mode 100644 index 0000000..551c93f --- /dev/null +++ b/src/hooks/useCoupon.ts @@ -0,0 +1,75 @@ +import { computed, reactive, ref, unref } from 'vue' + +export function useCoupon() { + const couponId = ref() + const setCouponId = (id: number) => { + couponId.value = id + } + return { + couponId, + setCouponId + } +} + +export function useZPaging(payload: any, requestApi: (params: any) => Promise) { + const paging = ref() + const state = reactive({ + totalParam: {} + }) + + /**获取列表数据 */ + const queryList = async (page_no: number, page_size: number, config = {}) => { + if (typeof requestApi !== 'function') return + try { + uni.showLoading({ + title: '加载中...' + }) + const params = { + ...payload, + ...state.totalParam, + ...config, + pageNo: page_no, + pageSize: page_size + } + const res = await requestApi?.(params) + paging.value.complete(res?.lists || res || []) + } catch (e) { + paging?.value?.complete(false) + } + uni.hideLoading() + } + /**更新参数 */ + const updateTotalParam = (params: any) => { + let nowParam: Record = {} + for (const key in params) { + nowParam[key] = params[key] + } + Object.assign(state.totalParam, nowParam) + } + /**刷新列表 */ + const refresh = (params: any) => { + updateTotalParam(params) + paging.value.reload() + } + + return { + paging, + queryList, + refresh + } +} + +export function useTabs() { + const tabStatus = ref(1) //tab状态 + const setTabIndex = computed(() => unref(tabStatus) - 1) //当前点击的tab索引 + + /**切换tab */ + const handleChangeTab = (index: number) => { + tabStatus.value = index + 1 + } + return { + tabStatus, + setTabIndex, + handleChangeTab + } +} diff --git a/src/hooks/useLockFn.ts b/src/hooks/useLockFn.ts new file mode 100644 index 0000000..47909e9 --- /dev/null +++ b/src/hooks/useLockFn.ts @@ -0,0 +1,40 @@ +import { computed, ref } from 'vue' +import { useAppStore } from '@/stores/app' + +export function useLockFn(fn: (...args: any[]) => Promise) { + const isLock = ref(false) + const lockFn = async (...args: any[]) => { + if (isLock.value) return + isLock.value = true + try { + const res = await fn(...args) + isLock.value = false + return res + } catch (e) { + isLock.value = false + throw e + } + } + return { + isLock, + lockFn + } +} +export function useToggle() { + const show = ref(false) + const handleToggle = () => { + show.value = !show.value + } + return { + show, + handleToggle + } +} + +export function useTabs() { + const appStore = useAppStore() + const tabsColor = computed(() => appStore.tabsColor) + return { + tabsColor + } +} diff --git a/src/hooks/useTouch.ts b/src/hooks/useTouch.ts new file mode 100644 index 0000000..acd5bca --- /dev/null +++ b/src/hooks/useTouch.ts @@ -0,0 +1,72 @@ +import { reactive } from 'vue' + +/** + * @description 触碰屏幕钩子函数 + * @return { Function } 暴露钩子 + */ +export function useTouch() { + // 最小移动距离 + const MIN_DISTANCE = 10 + + const touch = reactive({ + direction: '', + deltaX: 0, + deltaY: 0, + offsetX: 0, + offsetY: 0 + }) + + /** + * @description 计算距离 + * @return { string } 空字符串 + */ + const getDirection = (x: number, y: number) => { + if (x > y && x > MIN_DISTANCE) { + return 'horizontal' + } + if (y > x && y > MIN_DISTANCE) { + return 'vertical' + } + return '' + } + + /** + * @description 重置参数 + */ + const resetTouchStatus = () => { + touch.direction = '' + touch.deltaX = 0 + touch.deltaY = 0 + touch.offsetX = 0 + touch.offsetY = 0 + } + + /** + * @description 触发 + */ + const touchStart = (event: any) => { + resetTouchStatus() + const events = event.touches[0] + touch.startX = events.clientX + touch.startY = events.clientY + } + + /** + * @description 移动 + */ + const touchMove = (event: any) => { + const events = event.touches[0] + touch.deltaX = events.clientX - touch.startX + touch.deltaY = events.clientY - touch.startY + touch.offsetX = Math.abs(touch.deltaX) + touch.offsetY = Math.abs(touch.deltaY) + touch.direction = touch.direction || getDirection(touch.offsetX, touch.offsetY) + } + + return { + touch, + resetTouchStatus, + touchStart, + touchMove + } +} diff --git a/src/hooks/wechat.ts b/src/hooks/wechat.ts new file mode 100644 index 0000000..68cb6ae --- /dev/null +++ b/src/hooks/wechat.ts @@ -0,0 +1,153 @@ +// #ifdef H5 +import weixin from 'weixin-js-sdk' +import { useUserStore } from '@/stores/user' +import { apiJsConfig, apiCodeUrlGet, apiOALogin } from '@/api/app' + +//判断是否为安卓环境 +function _isAndroid() { + const u = navigator.userAgent + return u.indexOf('Android') > -1 || u.indexOf('Adr') > -1 +} + +export function getSignLink() { + if (typeof window.signLink === 'undefined' || window.signLink === '') { + window.signLink = location.href.split('#')[0] + } + return _isAndroid() ? location.href.split('#')[0] : window.signLink +} + +export function wxOaConfig() { + return new Promise((resolve, reject) => { + apiJsConfig('').then((res) => { + console.log('res:', res) //微信配置 + weixin.config({ + debug: false, // 开启调试模式 + appId: res.appid, // 必填,公众号的唯一标识 + timestamp: res.timestamp, // 必填,生成签名的时间戳 + nonceStr: res.nonceStr, // 必填,生成签名的随机串 + signature: res.signature, // 必填,签名 + jsApiList: res.jsApiList, // 必填,需要使用的JS接口列表 + success: () => { + resolve('success') + }, + fail: (res: any) => { + reject('weixin config is fail') + } + }) + }) + }) +} + +//获取微信登录url +export function getWxUrl() { + apiCodeUrlGet().then((res) => { + location.href = res.url + }) +} + +//微信授权 +export function authLogin(code) { + return new Promise((resolve, reject) => { + apiOALogin({ + code + }).then((res) => { + const { userStore } = useUserStore() + userStore.setToken(res.token) + resolve(res) + }) + }) +} + +export function wxOaReady() { + return new Promise((resolve, reject) => { + weixin.ready(() => { + resolve('success') + console.log('111') + }) + }) +} + +export function wxOaShare(options: Record) { + wxOaReady().then(() => { + const { shareTitle, shareLink, shareImage, shareDesc } = options + weixin.updateTimelineShareData({ + title: shareTitle, // 分享标题 + link: shareLink, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 + imgUrl: shareImage // 分享图标 + }) + // 发送给好友 + weixin.updateAppMessageShareData({ + title: shareTitle, // 分享标题 + link: shareLink, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 + imgUrl: shareImage, // 分享图标 + desc: shareDesc + }) + // 发送到tx微博 + weixin.onMenuShareWeibo({ + title: shareTitle, // 分享标题 + link: shareLink, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 + imgUrl: shareImage, // 分享图标 + desc: shareDesc + }) + }) +} + +export function wxOaPay(options: Record) { + console.log('options:', options) + + return new Promise((reslove, reject) => { + wxOaReady().then(() => { + console.log('微信支付', options) + weixin.chooseWXPay({ + appId: options.appId, + timestamp: options.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写 + nonceStr: options.nonceStr, // 支付签名随机串,不长于 32 位 + package: options.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***) + signType: options.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5' + paySign: options.paySign, // 支付签名 + success: (res: any) => { + reslove(res) + }, + cancel: (res: any) => { + reject(res) + }, + fail: (res: any) => { + reject(res) + } + }) + }) + }) +} + +export function wxOaAddress() { + return new Promise((reslove, reject) => { + wxOaReady().then(() => { + weixin.openAddress({ + success: (res: any) => { + reslove(res) + }, + fail: (res: any) => { + reject(res) + } + }) + }) + }) +} + +export function getLocation() { + return new Promise((reslove, reject) => { + wxOaReady().then(() => { + weixin.getLocation({ + type: 'gcj02', + success: (res: any) => { + reslove(res) + }, + fail: (res: any) => { + reject(res) + } + }) + }) + }) +} + +// #endif diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..fcc51ca --- /dev/null +++ b/src/main.ts @@ -0,0 +1,17 @@ +import { createSSRApp, ref } from 'vue' +import App from './App.vue' +import plugins from './plugins' +import { setupRouter } from './router' +import './styles/index.scss' + +export function createApp() { + const app = createSSRApp(App) + + Promise.resolve().then(() => { + setupRouter() + }) + app.use(plugins) + return { + app + } +} diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 0000000..7daa5e6 --- /dev/null +++ b/src/manifest.json @@ -0,0 +1,106 @@ +{ + "name" : "粤好生活", + "appid" : "__UNI__F081C07666", + "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" : [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + /* ios打包配置 */ + "ios" : {}, + /* SDK配置 */ + "sdkConfigs" : {} + } + }, + /* 快应用特有相关 */ + "quickapp" : {}, + /* 小程序特有相关 */ + "mp-weixin" : { + "appid" : "wxf712ba4cbc2df1e9", + "setting" : { + "urlCheck" : true, + "es6" : false, + "postcss" : true, + "minified" : false + }, + "usingComponents" : true, + "permission" : { + "scope.userLocation" : { + "desc" : "你的位置信息将用于小程序位置接口的效果展示" + } + }, + "requiredPrivateInfos" : [ "getLocation", "chooseAddress", "chooseLocation" ], + "unipush" : { + "enable" : false + } + }, + "mp-alipay" : { + "usingComponents" : true + }, + "mp-baidu" : { + "usingComponents" : true + }, + "mp-toutiao" : { + "usingComponents" : true, + "appid" : "ttf331858c6c0d199a01", + "setting" : { + "es6" : false, + "postcss" : false + } + }, + "uniStatistics" : { + "enable" : false + }, + "vueVersion" : "3", + "h5" : { + "sdkConfigs" : { + "maps" : { + "qqmap" : { + "key" : "ATEBZ-LCOWQ-BAP5J-4W6WL-QKZXS-4SFSD" + } + } + }, + "router" : { + "base" : "/mobile/", + "mode" : "history" + }, + "title" : "上门预约", + "devServer" : { + "https" : false /* 调试因调用本地的后端服务,故先改为false */ + } + } +} diff --git a/src/pages.json b/src/pages.json new file mode 100644 index 0000000..c979c0c --- /dev/null +++ b/src/pages.json @@ -0,0 +1,421 @@ +{ + "pages": [ + { + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "福源建筑生活", + "navigationStyle": "custom" + } + }, + { + "path": "pages/category/index", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "分类" + } + }, + { + "path": "pages/order/index", + "style": { + "navigationBarTitleText": "我的订单" + }, + "auth": true + }, + { + "path": "pages/order_buy/index", + "style": { + "navigationBarTitleText": "提交订单" + }, + "auth": true + }, + { + "path": "pages/payment_result/payment_result", + "style": { + "navigationBarTitleText": "支付结果" + }, + "auth": true + }, + { + "path": "pages/order_detail/index", + "style": { + "navigationBarTitleText": "订单详情", + "navigationBarBackgroundColor": "#1869FF", + "navigationBarTextStyle": "white" + }, + "auth": true + }, + { + "path": "pages/user/user", + "style": { + "navigationBarTitleText": "个人中心", + "navigationStyle": "custom" + } + }, + { + "path": "pages/activate/index", + "style": { + "navigationBarTitleText": "活动专区" + } + }, + { + "path": "pages/login/login", + "style": { + "navigationBarTitleText": "登录" + } + }, + { + "path": "pages/register/register", + "style": { + "navigationBarTitleText": "注册" + } + }, + { + "path": "pages/goods/index", + "style": { + "navigationBarTitleText": "商品详情" + } + }, + { + "path": "pages/forget_pwd/forget_pwd", + "style": { + "navigationBarTitleText": "忘记密码" + } + }, + { + "path": "pages/customer_service/customer_service", + "style": { + "navigationBarTitleText": "联系客服" + }, + "auth": true + }, + { + "path": "pages/user_set/user_set", + "style": { + "navigationBarTitleText": "个人设置" + }, + "auth": true + }, + { + "path": "pages/as_us/as_us", + "style": { + "navigationBarTitleText": "关于我们" + } + }, + { + "path": "pages/agreement/agreement", + "style": { + "navigationBarTitleText": "协议" + } + }, + { + "path": "pages/change_password/change_password", + "style": { + "navigationBarTitleText": "修改密码" + }, + "auth": true + }, + { + "path": "pages/user_data/user_data", + "style": { + "navigationBarTitleText": "个人资料" + }, + "auth": true + }, + { + "path": "pages/search/search", + "style": { + "navigationBarTitleText": "搜索" + } + }, + { + "path": "pages/webview/webview" + }, + { + "path": "pages/bind_mobile/bind_mobile", + "style": { + "navigationBarTitleText": "绑定手机号" + } + }, + { + "path": "pages/empty/empty", + "style": { + "navigationStyle": "custom" + } + }, + { + "path": "uni_modules/vk-uview-ui/components/u-avatar-cropper/u-avatar-cropper", + "style": { + "navigationBarTitleText": "头像裁剪", + "navigationBarBackgroundColor": "#000000" + } + } + ], + "subPackages": [ + { + "root": "bundle", + "pages": [ + { + "path": "pages/search/index", + "style": { + "navigationBarTitleText": "搜索" + } + }, + { + "path": "pages/user_address/index", + "style": { + "navigationBarTitleText": "地址管理" + }, + "auth": true + }, + { + "path": "pages/user_address_edit/index", + "style": { + "navigationBarTitleText": "地址详情" + }, + "auth": true + }, + { + "path": "pages/contact_service/index", + "style": { + "navigationBarTitleText": "联系客服" + }, + "auth": true + }, + { + "path": "pages/city/index", + "style": { + "navigationBarTitleText": "选择城市" + } + }, + { + "path": "pages/master_worker_list/index", + "style": { + "navigationBarTitleText": "师傅" + } + }, + { + "path": "pages/master_worker_detail/index", + "style": { + "navigationBarTitleText": "师傅主页" + } + }, + { + "path": "pages/service_order/index", + "style": { + "navigationBarTitleText": "我的接单" + }, + "auth": true + }, + { + "path": "pages/service_order_detail/index", + "style": { + "navigationBarTitleText": "服务详情" + } + }, + { + "path": "pages/category_goods_list/index", + "style": { + "navigationBarTitleText": "分类商品列表" + } + }, + { + "path": "pages/collection_list/index", + "style": { + "navigationBarTitleText": "我的收藏" + }, + "auth": true + }, + { + "path": "pages/appoint_time/index", + "style": { + "navigationBarTitleText": "上门时间" + }, + "auth": true + }, + { + "path": "pages/evaluate_goods/index", + "style": { + "navigationBarTitleText": "全部评价" + }, + "auth": true + }, + { + "path": "pages/evaluate_list/index", + "style": { + "navigationBarTitleText": "我的评价" + }, + "auth": true + }, + { + "path": "pages/evaluate_submit/index", + "style": { + "navigationBarTitleText": "提交评价" + }, + "auth": true + }, + { + "path": "pages/withdraw_record/withdraw_record", + "style": { + "navigationBarTitleText": "提现记录" + }, + "auth": true + }, + { + "path": "pages/withdrawal_details/withdrawal_details", + "style": { + "navigationBarTitleText": "提现详情" + } + }, + { + "path": "pages/user_wallet/user_wallet", + "style": { + "navigationBarTitleText": "我的钱包" + }, + "auth": true + }, + { + "path": "pages/user_recharge/user_recharge", + "style": { + "navigationBarTitleText": "充值" + }, + "auth": true + }, + { + "path": "pages/recharge_record/recharge_record", + "style": { + "navigationBarTitleText": "充值记录" + }, + "auth": true + }, + { + "path": "pages/account_detail/account_detail", + "style": { + "navigationBarTitleText": "余额明细" + }, + "auth": true + }, + { + "path": "pages/user_withdraw/user_withdraw", + "style": { + "navigationBarTitleText": "提现" + }, + "auth": true + }, + { + "path": "pages/my_coupon/my_coupon", + "style": { + "navigationBarTitleText": "我的优惠券" + }, + "auth": true + }, + { + "path": "pages/my_distributor/my_distributor", + "style": { + "navigationBarTitleText": "我的店铺" + }, + "auth": true + }, + { + "path": "pages/withdraw_money/index", + "style": { + "navigationBarTitleText": "提现", + "navigationBarBackgroundColor": "#2077FE", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/withdraw_distributor_record/index", + "style": { + "navigationBarTitleText": "提现记录", + "navigationStyle": "custom" + } + }, + { + "path": "pages/share_qrcode/index", + "style": { + "navigationBarTitleText": "分享二维码" + } + }, + { + "path": "pages/distributor_order/index", + "style": { + "navigationBarTitleText": "店铺订单", + "navigationStyle": "custom" + } + }, + { + "path": "pages/distributor_binding_user/index", + "style": { + "navigationBarTitleText": "店铺客户", + "navigationStyle": "custom" + } + }, + { + "path": "pages/receive_coupon/receive_coupon", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "pages/dist_order/index", + "style": { + "navigationBarTitleText": "订单详情" + } + }, + { + "path": "pages/service_explain/index", + "style": { + "navigationBarTitleText": "帮助中心" + } + }, + { + "path": "pages/coupon/index", + "style": { + "navigationBarTitleText": "领券中心" + }, + "auth": true + }, + { + "path": "pages/category_goods_coupon/goods_category", + "style": { + "navigationBarTitleText": "可抵扣商品" + } + }, + { + "path": "pages/category_goods_coupon/goods", + "style": { + "navigationBarTitleText": "可抵扣商品" + } + }, + { + "path": "pages/coupon/coupon_detail", + "style": { + "navigationBarTitleText": "优惠券详情" + } + }, + { + "path": "pages/coupon_order/coupon_order", + "style": { + "navigationBarTitleText": "选择优惠券" + } + } + ] + } + ], + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "商城", + "navigationBarBackgroundColor": "#FFFFFF", + "backgroundColor": "#F8F8F8", + "h5": { + "navigationStyle": "custom" + } + }, + "easycom": { + "custom": { + "^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue", + "^w-(.*)": "@/components/widgets/$1/$1.vue" + } + } +} diff --git a/src/pages/activate/comp/activate-list.vue b/src/pages/activate/comp/activate-list.vue new file mode 100644 index 0000000..0b07291 --- /dev/null +++ b/src/pages/activate/comp/activate-list.vue @@ -0,0 +1,138 @@ + + + + + diff --git a/src/pages/activate/index.vue b/src/pages/activate/index.vue new file mode 100644 index 0000000..45fab18 --- /dev/null +++ b/src/pages/activate/index.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/src/pages/agreement/agreement.vue b/src/pages/agreement/agreement.vue new file mode 100644 index 0000000..13028f8 --- /dev/null +++ b/src/pages/agreement/agreement.vue @@ -0,0 +1,35 @@ + + + + + diff --git a/src/pages/as_us/as_us.vue b/src/pages/as_us/as_us.vue new file mode 100644 index 0000000..22ee329 --- /dev/null +++ b/src/pages/as_us/as_us.vue @@ -0,0 +1,22 @@ + + + + + diff --git a/src/pages/bind_mobile/bind_mobile.vue b/src/pages/bind_mobile/bind_mobile.vue new file mode 100644 index 0000000..07f0df9 --- /dev/null +++ b/src/pages/bind_mobile/bind_mobile.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/src/pages/category/components/cate-card.vue b/src/pages/category/components/cate-card.vue new file mode 100644 index 0000000..924ac29 --- /dev/null +++ b/src/pages/category/components/cate-card.vue @@ -0,0 +1,153 @@ + + + + + diff --git a/src/pages/category/index.vue b/src/pages/category/index.vue new file mode 100644 index 0000000..7dbef69 --- /dev/null +++ b/src/pages/category/index.vue @@ -0,0 +1,151 @@ + + + + + diff --git a/src/pages/change_password/change_password.vue b/src/pages/change_password/change_password.vue new file mode 100644 index 0000000..71092cc --- /dev/null +++ b/src/pages/change_password/change_password.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/src/pages/customer_service/customer_service.vue b/src/pages/customer_service/customer_service.vue new file mode 100644 index 0000000..2daf7df --- /dev/null +++ b/src/pages/customer_service/customer_service.vue @@ -0,0 +1,26 @@ + + + + + diff --git a/src/pages/empty/empty.vue b/src/pages/empty/empty.vue new file mode 100644 index 0000000..76bd748 --- /dev/null +++ b/src/pages/empty/empty.vue @@ -0,0 +1,7 @@ + + + + + diff --git a/src/pages/forget_pwd/forget_pwd.vue b/src/pages/forget_pwd/forget_pwd.vue new file mode 100644 index 0000000..59b8c47 --- /dev/null +++ b/src/pages/forget_pwd/forget_pwd.vue @@ -0,0 +1,115 @@ + + + + + diff --git a/src/pages/goods/components/card.vue b/src/pages/goods/components/card.vue new file mode 100644 index 0000000..96f0ed1 --- /dev/null +++ b/src/pages/goods/components/card.vue @@ -0,0 +1,76 @@ + + + + + + diff --git a/src/pages/goods/components/goods-spec.vue b/src/pages/goods/components/goods-spec.vue new file mode 100644 index 0000000..ca9345c --- /dev/null +++ b/src/pages/goods/components/goods-spec.vue @@ -0,0 +1,127 @@ + + + + diff --git a/src/pages/goods/components/recommend-goods.vue b/src/pages/goods/components/recommend-goods.vue new file mode 100644 index 0000000..86be2c9 --- /dev/null +++ b/src/pages/goods/components/recommend-goods.vue @@ -0,0 +1,134 @@ + + + + + + diff --git a/src/pages/goods/components/sticky-spec.vue b/src/pages/goods/components/sticky-spec.vue new file mode 100644 index 0000000..be86416 --- /dev/null +++ b/src/pages/goods/components/sticky-spec.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/src/pages/goods/index.vue b/src/pages/goods/index.vue new file mode 100644 index 0000000..101af3f --- /dev/null +++ b/src/pages/goods/index.vue @@ -0,0 +1,595 @@ + + + + + diff --git a/src/pages/index/comp/activate-indoor.vue b/src/pages/index/comp/activate-indoor.vue new file mode 100644 index 0000000..32da4e3 --- /dev/null +++ b/src/pages/index/comp/activate-indoor.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/src/pages/index/comp/card.vue b/src/pages/index/comp/card.vue new file mode 100644 index 0000000..2740ec0 --- /dev/null +++ b/src/pages/index/comp/card.vue @@ -0,0 +1,65 @@ + + + + + + diff --git a/src/pages/index/comp/category-card.vue b/src/pages/index/comp/category-card.vue new file mode 100644 index 0000000..f369bf2 --- /dev/null +++ b/src/pages/index/comp/category-card.vue @@ -0,0 +1,81 @@ + + + + + + diff --git a/src/pages/index/comp/category-datalist.vue b/src/pages/index/comp/category-datalist.vue new file mode 100644 index 0000000..95fb361 --- /dev/null +++ b/src/pages/index/comp/category-datalist.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/src/pages/index/comp/category.vue b/src/pages/index/comp/category.vue new file mode 100644 index 0000000..956310c --- /dev/null +++ b/src/pages/index/comp/category.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/src/pages/index/comp/hot-list.vue b/src/pages/index/comp/hot-list.vue new file mode 100644 index 0000000..0445917 --- /dev/null +++ b/src/pages/index/comp/hot-list.vue @@ -0,0 +1,114 @@ + + + + + diff --git a/src/pages/index/comp/master-list.vue b/src/pages/index/comp/master-list.vue new file mode 100644 index 0000000..316d2e0 --- /dev/null +++ b/src/pages/index/comp/master-list.vue @@ -0,0 +1,79 @@ + + + + + diff --git a/src/pages/index/comp/new-goods.vue b/src/pages/index/comp/new-goods.vue new file mode 100644 index 0000000..4f24cc0 --- /dev/null +++ b/src/pages/index/comp/new-goods.vue @@ -0,0 +1,103 @@ + + + + + diff --git a/src/pages/index/comp/sticky-category.vue b/src/pages/index/comp/sticky-category.vue new file mode 100644 index 0000000..cfc29b4 --- /dev/null +++ b/src/pages/index/comp/sticky-category.vue @@ -0,0 +1,231 @@ + + + + + + diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue new file mode 100644 index 0000000..043489f --- /dev/null +++ b/src/pages/index/index.vue @@ -0,0 +1,480 @@ + + + + + diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue new file mode 100644 index 0000000..a911b15 --- /dev/null +++ b/src/pages/login/login.vue @@ -0,0 +1,560 @@ + + + + + diff --git a/src/pages/order/components/order-card.vue b/src/pages/order/components/order-card.vue new file mode 100644 index 0000000..df82386 --- /dev/null +++ b/src/pages/order/components/order-card.vue @@ -0,0 +1,186 @@ + + + + + diff --git a/src/pages/order/components/order-list.vue b/src/pages/order/components/order-list.vue new file mode 100644 index 0000000..1924cb8 --- /dev/null +++ b/src/pages/order/components/order-list.vue @@ -0,0 +1,108 @@ + + + + + + diff --git a/src/pages/order/index.vue b/src/pages/order/index.vue new file mode 100644 index 0000000..8e2c8db --- /dev/null +++ b/src/pages/order/index.vue @@ -0,0 +1,227 @@ + + + + + diff --git a/src/pages/order_buy/index.vue b/src/pages/order_buy/index.vue new file mode 100644 index 0000000..31b28ca --- /dev/null +++ b/src/pages/order_buy/index.vue @@ -0,0 +1,489 @@ + + + + + diff --git a/src/pages/order_detail/index.vue b/src/pages/order_detail/index.vue new file mode 100644 index 0000000..0936749 --- /dev/null +++ b/src/pages/order_detail/index.vue @@ -0,0 +1,402 @@ + + + + + diff --git a/src/pages/payment_result/payment_result.vue b/src/pages/payment_result/payment_result.vue new file mode 100644 index 0000000..7382c8f --- /dev/null +++ b/src/pages/payment_result/payment_result.vue @@ -0,0 +1,142 @@ + + + + + diff --git a/src/pages/register/register.vue b/src/pages/register/register.vue new file mode 100644 index 0000000..ca12ffc --- /dev/null +++ b/src/pages/register/register.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/src/pages/search/component/suggest.vue b/src/pages/search/component/suggest.vue new file mode 100644 index 0000000..341f70c --- /dev/null +++ b/src/pages/search/component/suggest.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/src/pages/search/search.vue b/src/pages/search/search.vue new file mode 100644 index 0000000..b50878d --- /dev/null +++ b/src/pages/search/search.vue @@ -0,0 +1,127 @@ + + + + + diff --git a/src/pages/user/user.vue b/src/pages/user/user.vue new file mode 100644 index 0000000..24ea2c0 --- /dev/null +++ b/src/pages/user/user.vue @@ -0,0 +1,157 @@ + + + + + + diff --git a/src/pages/user_data/user_data.vue b/src/pages/user_data/user_data.vue new file mode 100644 index 0000000..7e0d935 --- /dev/null +++ b/src/pages/user_data/user_data.vue @@ -0,0 +1,394 @@ + + + + + diff --git a/src/pages/user_set/user_set.vue b/src/pages/user_set/user_set.vue new file mode 100644 index 0000000..a9beb1e --- /dev/null +++ b/src/pages/user_set/user_set.vue @@ -0,0 +1,186 @@ + + + + + diff --git a/src/pages/webview/webview.vue b/src/pages/webview/webview.vue new file mode 100644 index 0000000..e52cc43 --- /dev/null +++ b/src/pages/webview/webview.vue @@ -0,0 +1,16 @@ + + + + + diff --git a/src/plugins/index.ts b/src/plugins/index.ts new file mode 100644 index 0000000..62bb0ac --- /dev/null +++ b/src/plugins/index.ts @@ -0,0 +1,12 @@ +import { isFunction } from '@vue/shared' +import { App } from 'vue' +const modules = import.meta.globEager('./modules/**/*.ts') + +export default { + install: (app: App) => { + for (const module of Object.values(modules)) { + const fun = module.default + isFunction(fun) && fun(app) + } + } +} diff --git a/src/plugins/modules/pinia.ts b/src/plugins/modules/pinia.ts new file mode 100644 index 0000000..c5b769f --- /dev/null +++ b/src/plugins/modules/pinia.ts @@ -0,0 +1,6 @@ +import { App } from 'vue' +import { createPinia } from 'pinia' +const pinia = createPinia() +export default (app: App) => { + app.use(pinia) +} diff --git a/src/plugins/modules/uview.ts b/src/plugins/modules/uview.ts new file mode 100644 index 0000000..52abc1e --- /dev/null +++ b/src/plugins/modules/uview.ts @@ -0,0 +1,7 @@ +import { App } from 'vue' +import uView from '@/uni_modules/vk-uview-ui' + +export default (app: App) => { + // 使用 uView UI + app.use(uView) +} diff --git a/src/plugins/modules/vconsole.ts b/src/plugins/modules/vconsole.ts new file mode 100644 index 0000000..74cd89f --- /dev/null +++ b/src/plugins/modules/vconsole.ts @@ -0,0 +1,14 @@ +// #ifdef H5 +// 提交前需要注释 本地调试使用 +// import Vconsole from 'vconsole' +// import { isDevMode } from '@/utils/env' +// #endif + +export default () => { + // #ifdef H5 + // if (isDevMode()) { + // const vConsole = new Vconsole() + // return vConsole + // } + // #endif +} diff --git a/src/router/index.ts b/src/router/index.ts new file mode 100644 index 0000000..56e42b1 --- /dev/null +++ b/src/router/index.ts @@ -0,0 +1,68 @@ +/* + * @Author: micky 1254597151@qq.com + * @Date: 2023-08-14 15:38:40 + * @LastEditors: micky 1254597151@qq.com + * @LastEditTime: 2023-09-07 16:01:06 + * @FilePath: \housekeeping-uniapp\src\router\index.ts + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +import { BACK_URL } from '@/enums/cacheEnums' +import { useUserStore } from '@/stores/user' +import { getToken } from '@/utils/auth' +import cache from '@/utils/cache' +import { routes } from './routes' +import { isWeixinClient } from '@/utils/client' +import { wxOaConfig } from '@/hooks/wechat' + +const whiteList = ['register', 'login', 'forget_pwd'] +const list = ['navigateTo', 'redirectTo', 'reLaunch', 'switchTab'] +list.forEach(item => { + uni.addInterceptor(item, { + invoke(e) { + // 获取要跳转的页面路径(url去掉"?"和"?"后的参数) + const url = e.url?.split('?')[0] + const currentRoute = routes.find(item => { + return url === item.path + }) + // 需要登录并且没有token + if (currentRoute?.auth && !getToken()) { + if (currentRoute.path === '/pages/order/index') { + cache.set(BACK_URL, currentRoute.path) + } + uni.navigateTo({ + url: '/pages/login/login' + }) + return false + } + // #ifdef H5 + // 添加定时器防止拿到的域名是上一个域名 + setTimeout(async () => { + if (isWeixinClient()) { + // jssdk配置 + await wxOaConfig() + } + }) + // #endif + return e + }, + fail(err) { + // 失败回调拦截 + console.log(err) + } + }) +}) + +export function setupRouter() { + // #ifdef H5 + const app = getApp() + app.$router.afterEach((to: any, from: any) => { + const index = whiteList.findIndex(item => from.path.includes(item) || from.path === '/') + const userStore = useUserStore() + if (index == -1 && !userStore.isLogin) { + //保存登录前的路径 + cache.set(BACK_URL, from.fullPath) + } + }) + + // #endif +} diff --git a/src/router/routes.ts b/src/router/routes.ts new file mode 100644 index 0000000..fa33c22 --- /dev/null +++ b/src/router/routes.ts @@ -0,0 +1,47 @@ +import PagesJSON from '../pages.json' +const CONFIG = { + includes: ['path', 'aliasPath', 'name', 'auth'] +} + +function getPagesRoutes(pages: any[], rootPath = null) { + const routes: any[] = [] + for (let i = 0; i < pages.length; i++) { + const item = pages[i] + const route: any = {} + for (let j = 0; j < CONFIG.includes.length; j++) { + const key = CONFIG.includes[j] + let value = item[key] + if (key === 'path') { + value = rootPath ? `/${rootPath}/${value}` : `/${value}` + } + if (key === 'aliasPath' && i == 0 && rootPath == null) { + route[key] = route[key] || '/' + } else if (value !== undefined) { + route[key] = value + } + } + routes.push(route) + } + return routes +} + +function getSubPackagesRoutes(pagesJson: any) { + const { subPackages } = pagesJson + let routes: any[] = [] + if (subPackages == null || subPackages.length == 0) { + return [] + } + for (let i = 0; i < subPackages.length; i++) { + const subPages = subPackages[i].pages + const root = subPackages[i].root + const subRoutes = getPagesRoutes(subPages, root) + routes = routes.concat(subRoutes) + } + return routes +} + +export function generateRoutes() { + return getPagesRoutes(PagesJSON.pages).concat(getSubPackagesRoutes(PagesJSON)) +} + +export const routes = generateRoutes() diff --git a/src/static/images/download.png b/src/static/images/download.png new file mode 100644 index 0000000..82e03c7 Binary files /dev/null and b/src/static/images/download.png differ diff --git a/src/static/images/empty/address.png b/src/static/images/empty/address.png new file mode 100644 index 0000000..4b60c4a Binary files /dev/null and b/src/static/images/empty/address.png differ diff --git a/src/static/images/empty/collection.png b/src/static/images/empty/collection.png new file mode 100644 index 0000000..2a0fb66 Binary files /dev/null and b/src/static/images/empty/collection.png differ diff --git a/src/static/images/home/cloud.png b/src/static/images/home/cloud.png new file mode 100644 index 0000000..5bcd03f Binary files /dev/null and b/src/static/images/home/cloud.png differ diff --git a/src/static/images/home/home_bg.png b/src/static/images/home/home_bg.png new file mode 100644 index 0000000..7a20026 Binary files /dev/null and b/src/static/images/home/home_bg.png differ diff --git a/src/static/images/home/wave.png b/src/static/images/home/wave.png new file mode 100644 index 0000000..bd1042d Binary files /dev/null and b/src/static/images/home/wave.png differ diff --git a/src/static/images/icon/balance.png b/src/static/images/icon/balance.png new file mode 100644 index 0000000..f6cf07e Binary files /dev/null and b/src/static/images/icon/balance.png differ diff --git a/src/static/images/icon/brokerage.png b/src/static/images/icon/brokerage.png new file mode 100644 index 0000000..52c98dc Binary files /dev/null and b/src/static/images/icon/brokerage.png differ diff --git a/src/static/images/icon/icon_code.png b/src/static/images/icon/icon_code.png new file mode 100644 index 0000000..143e6d9 Binary files /dev/null and b/src/static/images/icon/icon_code.png differ diff --git a/src/static/images/icon/icon_mobile.png b/src/static/images/icon/icon_mobile.png new file mode 100644 index 0000000..a5e7681 Binary files /dev/null and b/src/static/images/icon/icon_mobile.png differ diff --git a/src/static/images/icon/icon_null_select.png b/src/static/images/icon/icon_null_select.png new file mode 100644 index 0000000..51ea266 Binary files /dev/null and b/src/static/images/icon/icon_null_select.png differ diff --git a/src/static/images/icon/icon_password.png b/src/static/images/icon/icon_password.png new file mode 100644 index 0000000..7c49533 Binary files /dev/null and b/src/static/images/icon/icon_password.png differ diff --git a/src/static/images/icon/icon_pay_success.png b/src/static/images/icon/icon_pay_success.png new file mode 100644 index 0000000..4d0aa7f Binary files /dev/null and b/src/static/images/icon/icon_pay_success.png differ diff --git a/src/static/images/icon/icon_select.png b/src/static/images/icon/icon_select.png new file mode 100644 index 0000000..fff1c34 Binary files /dev/null and b/src/static/images/icon/icon_select.png differ diff --git a/src/static/images/icon/icon_user.png b/src/static/images/icon/icon_user.png new file mode 100644 index 0000000..2144a46 Binary files /dev/null and b/src/static/images/icon/icon_user.png differ diff --git a/src/static/images/icon/icon_visit.png b/src/static/images/icon/icon_visit.png new file mode 100644 index 0000000..c63a4ad Binary files /dev/null and b/src/static/images/icon/icon_visit.png differ diff --git a/src/static/images/icon/icon_wait.png b/src/static/images/icon/icon_wait.png new file mode 100644 index 0000000..5452393 Binary files /dev/null and b/src/static/images/icon/icon_wait.png differ diff --git a/src/static/images/icon/icon_wx.png b/src/static/images/icon/icon_wx.png new file mode 100644 index 0000000..4810271 Binary files /dev/null and b/src/static/images/icon/icon_wx.png differ diff --git a/src/static/images/icon/recharge.png b/src/static/images/icon/recharge.png new file mode 100644 index 0000000..3db0576 Binary files /dev/null and b/src/static/images/icon/recharge.png differ diff --git a/src/static/images/icon/withdraw.png b/src/static/images/icon/withdraw.png new file mode 100644 index 0000000..ee26513 Binary files /dev/null and b/src/static/images/icon/withdraw.png differ diff --git a/src/static/images/icon_account_login.png b/src/static/images/icon_account_login.png new file mode 100644 index 0000000..391844f Binary files /dev/null and b/src/static/images/icon_account_login.png differ diff --git a/src/static/images/icon_city_address.png b/src/static/images/icon_city_address.png new file mode 100644 index 0000000..ed474d2 Binary files /dev/null and b/src/static/images/icon_city_address.png differ diff --git a/src/static/images/icon_clear.png b/src/static/images/icon_clear.png new file mode 100644 index 0000000..ae86401 Binary files /dev/null and b/src/static/images/icon_clear.png differ diff --git a/src/static/images/icon_close.png b/src/static/images/icon_close.png new file mode 100644 index 0000000..33d9e48 Binary files /dev/null and b/src/static/images/icon_close.png differ diff --git a/src/static/images/icon_code_login.png b/src/static/images/icon_code_login.png new file mode 100644 index 0000000..005aed1 Binary files /dev/null and b/src/static/images/icon_code_login.png differ diff --git a/src/static/images/icon_collection.png b/src/static/images/icon_collection.png new file mode 100644 index 0000000..0fa13dd Binary files /dev/null and b/src/static/images/icon_collection.png differ diff --git a/src/static/images/icon_collection_s2.png b/src/static/images/icon_collection_s2.png new file mode 100644 index 0000000..4608be0 Binary files /dev/null and b/src/static/images/icon_collection_s2.png differ diff --git a/src/static/images/icon_password_login.png b/src/static/images/icon_password_login.png new file mode 100644 index 0000000..00c73bc Binary files /dev/null and b/src/static/images/icon_password_login.png differ diff --git a/src/static/images/icon_pay.png b/src/static/images/icon_pay.png new file mode 100644 index 0000000..7d9cd32 Binary files /dev/null and b/src/static/images/icon_pay.png differ diff --git a/src/static/images/icon_select.png b/src/static/images/icon_select.png new file mode 100644 index 0000000..f9338a9 Binary files /dev/null and b/src/static/images/icon_select.png differ diff --git a/src/static/images/icon_success.png b/src/static/images/icon_success.png new file mode 100644 index 0000000..2baf514 Binary files /dev/null and b/src/static/images/icon_success.png differ diff --git a/src/static/images/icon_unselect.png b/src/static/images/icon_unselect.png new file mode 100644 index 0000000..bd9594b Binary files /dev/null and b/src/static/images/icon_unselect.png differ diff --git a/src/static/images/icon_user_about.png b/src/static/images/icon_user_about.png new file mode 100644 index 0000000..4e36799 Binary files /dev/null and b/src/static/images/icon_user_about.png differ diff --git a/src/static/images/icon_wait.png b/src/static/images/icon_wait.png new file mode 100644 index 0000000..c2f9b70 Binary files /dev/null and b/src/static/images/icon_wait.png differ diff --git a/src/static/images/index.jpg b/src/static/images/index.jpg new file mode 100644 index 0000000..75ce938 Binary files /dev/null and b/src/static/images/index.jpg differ diff --git a/src/static/images/kefu.png b/src/static/images/kefu.png new file mode 100644 index 0000000..d49b5a4 Binary files /dev/null and b/src/static/images/kefu.png differ diff --git a/src/static/images/kefu_black.png b/src/static/images/kefu_black.png new file mode 100644 index 0000000..ae603af Binary files /dev/null and b/src/static/images/kefu_black.png differ diff --git a/src/static/images/order-detail-bg.png b/src/static/images/order-detail-bg.png new file mode 100644 index 0000000..b84af94 Binary files /dev/null and b/src/static/images/order-detail-bg.png differ diff --git a/src/static/images/phone.png b/src/static/images/phone.png new file mode 100644 index 0000000..9c9fc4b Binary files /dev/null and b/src/static/images/phone.png differ diff --git a/src/static/images/received.png b/src/static/images/received.png new file mode 100644 index 0000000..b52cc48 Binary files /dev/null and b/src/static/images/received.png differ diff --git a/src/static/images/recharge_uccess.png b/src/static/images/recharge_uccess.png new file mode 100644 index 0000000..8cfa419 Binary files /dev/null and b/src/static/images/recharge_uccess.png differ diff --git a/src/static/images/service/1.jpg b/src/static/images/service/1.jpg new file mode 100644 index 0000000..c724711 Binary files /dev/null and b/src/static/images/service/1.jpg differ diff --git a/src/static/images/service/2.jpg b/src/static/images/service/2.jpg new file mode 100644 index 0000000..425a3ac Binary files /dev/null and b/src/static/images/service/2.jpg differ diff --git a/src/static/images/share-friend.png b/src/static/images/share-friend.png new file mode 100644 index 0000000..2e2879f Binary files /dev/null and b/src/static/images/share-friend.png differ diff --git a/src/static/images/share.png b/src/static/images/share.png new file mode 100644 index 0000000..e8eb127 Binary files /dev/null and b/src/static/images/share.png differ diff --git a/src/static/images/user/default_avatar.png b/src/static/images/user/default_avatar.png new file mode 100644 index 0000000..de31d02 Binary files /dev/null and b/src/static/images/user/default_avatar.png differ diff --git a/src/stores/app.ts b/src/stores/app.ts new file mode 100644 index 0000000..afb6eef --- /dev/null +++ b/src/stores/app.ts @@ -0,0 +1,249 @@ +/* eslint-disable prettier/prettier */ +import { defineStore } from 'pinia' +import { getConfig } from '@/api/app' +import { isWeixinClient } from '@/utils/client' +// #ifdef H5 +import { getLocation } from '@/hooks/wechat' +// #endif +import { getGeocoderCoordinate } from '@/api/app' + +interface City { + name: string | null | undefined + city_id: number | null | undefined | string + latitude: string | null | undefined + longitude: string | null | undefined +} + +interface AppSate { + config: Record + cityInfo: City + sysInfo: Record + tabsColor: Record +} +export const useAppStore = defineStore({ + id: 'appStore', + state: (): AppSate => ({ + // 公共配置 + config: {}, + // 城市信息 + cityInfo: { + name: '选择', + city_id: '', + latitude: '', + longitude: '' + }, + // 系统信息 + sysInfo: {}, + tabsColor: { + bgColor: '#fff', + activeColor: '#2468F2', + inactiveColor: '#333' + } + }), + getters: { + getWebsiteConfig: state => state.config.website || {}, + getLoginConfig: state => state.config.login || {}, + getTabbarConfig: state => state.config.tabbar || [], + getStyleConfig: state => state.config.style || {}, + getH5Config: state => state.config.h5 || {}, + cityData: state => state.cityInfo + }, + actions: { + getImageUrl(url: string) { + return url ? `${this.config.domain}${url}` : '' + // return url || '' + }, + async getConfig() { + const data = await getConfig() + this.config = data + }, + + setCityInfo(city: City) { + this.cityInfo = city + uni.$emit('refreshhome') + }, + + // 获取系统信息 + getSystemInfoFn() { + uni.getSystemInfo({ + success: res => { + const { statusBarHeight, platform }: any = res + let navHeight + if (platform == 'ios' || platform == 'devtools') { + navHeight = statusBarHeight + 44 + } else { + navHeight = statusBarHeight + 48 + } + this.sysInfo = { + ...res, + navHeight + } + console.log('获取系统信息', res) + }, + fail(err) { + console.log(err) + } + }) + }, + + // 初始化获取位置 + async getLocationFunc() { + let res: any + const slef = this + try { + // eslint-disable-next-line prettier/prettier + if (isWeixinClient()) { + try { + res = await getLocation() + + slef.initCityFunc(res.latitude, res.longitude) + console.log('获取位置成功:', res) + } catch (e) { + console.log('获取位置失败:', e) + } + } else { + const obj = { + name: '广州市', // 市 + city_id: 440100, + latitude: '23.120049', + longitude: '113.30765' + } + this.setCityInfo(obj) + + // slef.initCityFunc() + // uni.getLocation({ + // // #ifndef APP + // type: 'gcj02', + // // #endif + // success(res) { + // console.log('success'); + + // slef.initCityFunc(res.latitude, res.longitude) + // }, + // fail(result) { + // console.log('fail') + // // #ifdef MP + // if (!slef.sysInfo.locationEnabled) { + // return uni.showModal({ + // title: '温馨提示', + // content: '您的手机定位还未开启后,开启后重新进入小程序或刷新' + // }) + // } + // slef.getAuthorizeFunc() + // // #endif + // } + // }) + } + } catch (err) { + console.log('失败原因:', err) + } + }, + + // 小程序未开启定位或拒绝授权 + async getAuthorizeFunc() { + const data: any = await uni.showModal({ + title: '您已拒绝地理位置权限', + content: '是否进入权限管理,调整授权?' + }) + if (data.confirm) { + const data: any = await uni.openSetting() + if (data.authSetting['scope.userLocation']) this.getLocation() + } + }, + + // 逆解析地址 + async initCityFunc(latitude: string, longitude: string) { + try { + console.log('当前经纬度:', latitude, longitude) + // const res1 = await getGeocoderCoordinate({ + // lat: latitude, + // lng: longitude + // }) + // const obj = { + // name: res1.amapGenCoderResponse.amapAddressComponent.city, // 市 + // city_id: res1.cityId, + // latitude, + // longitude + // } + // console.log("当前城市:", obj) + + const obj = { + name: '广州市', // 市 + city_id: 440100, + latitude: '23.120049', + longitude: '113.30765' + } + this.setCityInfo(obj) + } catch (error) { + console.log('逆解析地址:', error) + + //! 调试改为广州市 + const obj = { + name: '广州市', // 市 + city_id: 440100, + latitude: '23.120049', + longitude: '113.30765' + } + this.setCityInfo(obj) + } + }, + getLocation() { + const self = this + + uni.getLocation({ + // #ifndef APP + type: 'gcj02', + // #endif + success: async res => { + const res1 = await getGeocoderCoordinate({ + lat: res.latitude, + lng: res.longitude + }) + const obj = { + name: res1.amapGenCoderResponse.amapAddressComponent.city, // 市 + city_id: res1.cityId, + latitude: res.latitude, + longitude: res.longitude + } + this.setCityInfo(obj) + } + }) + }, + setInfo() {}, + async checkForUpdate() { + if (uni.canIUse('getUpdateManager')) { + const updateManager = uni.getUpdateManager() + //检测版本更新 + updateManager.onCheckForUpdate(function (res) { + if (res.hasUpdate) { + updateManager.onUpdateReady(function () { + uni.showModal({ + title: '温馨提示', + content: '检测到新版本,是否重启小程序?', + showCancel: false, + success: function (res) { + if (res.confirm) { + // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 + updateManager.applyUpdate() + } + } + }) + }) + updateManager.onUpdateFailed(function () { + // 新版本下载失败 + uni.showModal({ + title: '已有新版本', + content: '请您删除小程序,重新搜索进入' + }) + }) + } + }) + } else { + uni.showModal({ + title: '溫馨提示', + content: '当前微信版本过低,无法获取小程序更新,请升级到最新微信版本后重试。' + }) + } + } + } +}) diff --git a/src/stores/user.ts b/src/stores/user.ts new file mode 100644 index 0000000..2f22277 --- /dev/null +++ b/src/stores/user.ts @@ -0,0 +1,63 @@ +import { apiBindingDistId } from '@/api/app' +import { getUserCenter } from '@/api/user' +import { DIST_ID, TOKEN_KEY, USER_INFO } from '@/enums/cacheEnums' +import cache from '@/utils/cache' +import { defineStore } from 'pinia' + +interface UserSate { + userInfo: Record + token: string | null + temToken: string | null + distId: number | null +} +export const useUserStore = defineStore({ + id: 'userStore', + state: (): UserSate => ({ + userInfo: cache.get(USER_INFO) || {}, + token: cache.get(TOKEN_KEY) || null, + temToken: null, + distId: cache.get(DIST_ID) || null //分销id + }), + getters: { + isLogin: (state) => !!state.token + }, + actions: { + async getUser() { + if (this.token || this.temToken) { + const data = await getUserCenter({ + token: this.token || this.temToken + }) + this.userInfo = data + cache.set(USER_INFO, data) + } + }, + login(token: string) { + this.token = token + cache.set(TOKEN_KEY, token) + }, + logout() { + this.token = '' + this.userInfo = {} + this.distId = null + cache.remove(TOKEN_KEY) + cache.remove(USER_INFO) + cache.remove(DIST_ID) + }, + /**扫描分销码进来的用户 */ + setDistId(distId: number) { + this.distId = distId + cache.set(DIST_ID, distId) + }, + /**绑定分销员id */ + async bindingDistId() { + const params = { + userId: this.userInfo.id, + distributorId: this.distId + } + try { + await apiBindingDistId(params) + } catch (e) { } + } + + } +}) diff --git a/src/styles/index.scss b/src/styles/index.scss new file mode 100644 index 0000000..071f039 --- /dev/null +++ b/src/styles/index.scss @@ -0,0 +1,3 @@ +@import './tailwind.css'; +@import './public.scss'; +@import '../uni_modules/vk-uview-ui/index.scss'; diff --git a/src/styles/public.scss b/src/styles/public.scss new file mode 100644 index 0000000..46f9a15 --- /dev/null +++ b/src/styles/public.scss @@ -0,0 +1,90 @@ +page { + background-color: $u-bg-color; + font-size: 28rpx; +} + +.text_hidden { + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; +} + +.title-active { + position: relative; + + &::before { + content: ''; + position: absolute; + left: 0; + top: 50%; + transform: translateY(-50%); + width: 10rpx; + height: 50%; + background: $u-type-primary; + } +} + +button::after { + border: none; +} + +@mixin flex { + display: flex; +} + +@mixin flex-column { + @include flex; + flex-direction: column; +} + +@mixin flex-justify { + @include flex; + justify-content: space-between; +} + +@mixin flex-center { + @include flex-column; + align-items: center; + text-align: center; +} + +@mixin center { + display: flex; + align-items: center; + justify-content: center; +} + +.count { + position: absolute; + top: 0; + left: 0; + background-color: $blue2; + border-radius: 12rpx 0 12rpx 0; + color: $white; + font-size: 20rpx; + padding: 0 12rpx; +} + +@mixin lineClamp($lineClamp: 2) { + -webkit-line-clamp: $lineClamp; +} +.overflow-ellipsis-line { + @include lineClamp; + overflow: hidden; + text-overflow: ellipsis; + word-break: break-all; + -webkit-box-orient: vertical; + display: -webkit-box; +} +.ellipsis-line1 { + @include lineClamp(1); +} +.custom-button-bgColor, +.bg-primary { + // background-color: $blue5; + background: linear-gradient(90deg, rgba(24, 105, 255, 1) 0%, rgba(43, 151, 252, 1) 100%); +} +.text-primary { + color: $blue5; +} diff --git a/src/styles/tailwind.css b/src/styles/tailwind.css new file mode 100644 index 0000000..2b388ff --- /dev/null +++ b/src/styles/tailwind.css @@ -0,0 +1,5 @@ +/* #ifdef H5 */ +@tailwind base; +/* #endif */ + +@tailwind utilities; diff --git a/src/styles/variable.scss b/src/styles/variable.scss new file mode 100644 index 0000000..12d3534 --- /dev/null +++ b/src/styles/variable.scss @@ -0,0 +1,15 @@ +$white: #fff; +$white1: #f8f8f9; +$white3: #eee; +$white4: #f3f3f4; +$gray1: #777; +$gray2: #999; +$gray3: #dedede; +$gray4: #46c6a8; +$blue1: #485ffc; +$blue2: #2799ff; +$blue3: #495aff; +$blue4: #4481eb; +$blue5: #2468f2; +$red: #cc463d; +$black: #000; diff --git a/src/uni.scss b/src/uni.scss new file mode 100644 index 0000000..f77bdc6 --- /dev/null +++ b/src/uni.scss @@ -0,0 +1,39 @@ +@import '@/uni_modules/vk-uview-ui/theme.scss'; +@import '@/styles/variable.scss'; +@import '@/styles/public.scss'; + +$u-main-color: #333333; +$u-content-color: #666666; +$u-tips-color: #999999; +$u-light-color: #c0c4cc; +$u-border-color: #e5e5e5; +$u-bg-color: #f8f8f9; +$u-disabled-color: #c8c9cc; + +$u-type-primary: #1296db; +$u-type-primary-light: #ecf5ff; +$u-type-primary-disabled: #a0cfff; +$u-type-primary-dark: #2b85e4; + +$u-type-warning: #ff9900; +$u-type-warning-disabled: #fcbd71; +$u-type-warning-dark: #f29100; +$u-type-warning-light: #fdf6ec; + +$u-type-success: #19be6b; +$u-type-success-disabled: #71d5a1; +$u-type-success-dark: #18b566; +$u-type-success-light: #dbf1e1; + +$u-type-error: #f56c6c; +$u-type-error-disabled: #fab6b6; +$u-type-error-dark: #dd6161; +$u-type-error-light: #fef0f0; + +$u-type-info: #909399; +$u-type-info-disabled: #c8c9cc; +$u-type-info-dark: #82848a; +$u-type-info-light: #f4f4f5; + +$u-form-item-height: 60rpx; +$u-form-item-border-color: #e5e5e5; diff --git a/src/uni_modules/vk-uview-ui/changelog.md b/src/uni_modules/vk-uview-ui/changelog.md new file mode 100644 index 0000000..8ef6788 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/changelog.md @@ -0,0 +1,118 @@ +## 1.3.12(2022-08-30) +* 【优化】`u-keyboard` 组件内部细节。 +## 1.3.11(2022-08-30) +* 【修复】`u-subsection` 组件的 `list` 属性不支持动态修改的问题。 +## 1.3.10(2022-07-30) +* 【优化】上传组件部分细节 +## 1.3.9(2022-07-07) +* 【更新】省市区数据源 +* 【优化】`u-subsection` 组件支持在右上角显示数字角标 +```html + +``` + +```js +export default { + data() { + return { + list: [ + { + name: '待发货', + num: 10 + }, + { + name: '待付款', + num: 5 + }, + { + name: '待评价', + num: 15 + } + ] + } + } +} +``` +## 1.3.8(2022-06-13) +* 【优化】组件 `u-icon`,使之更方便的兼容第三方icon(满足规则自动计算customPrefix) +**规则如下:** +* 当 `name` 中包含 `-icon-` 字符串时 +* 如 `vk-icon-goods`,则组件的 `customPrefix` 属性自动识别为 `vk-icon` ,`name`属性 自动识别为 `goods` +* 如 `vk-2-icon-goods-list`,则组件的 `customPrefix` 属性自动识别为 `vk-2-icon` ,`name`属性 自动识别为 `goods-list` +## 1.3.7(2022-06-10) +* 【优化】组件 `u-action-sheet` `u-calendar` `u-dropdown-item` `u-field` `u-input` `u-keyboard` `u-modal` `u-radio-group` `u-rate` `u-search` `u-slider` `u-switch` `u-tabbar` `u-waterfall` 在 `vue3` 模式下的细节问题。 +## 1.3.6(2022-06-10) +* 【优化】组件 `u-action-sheet` `u-calendar` `u-dropdown-item` `u-field` `u-input` `u-keyboard` `u-modal` `u-radio-group` `u-rate` `u-search` `u-slider` `u-switch` `u-tabbar` `u-waterfall` 在 `vue3` 模式下的细节问题。 +## 1.3.5(2022-05-28) +* 【优化】组件 `u-mask` `u-popup` `u-select` `u-modal` `u-keyboard` `u-calendar` `u-action-sheet` `u-picker` 均新增 `blur` 属性,可用于设置弹出遮罩的模糊度,默认为0(不模糊) +* ![](https://vkceyugu.cdn.bspapp.com/VKCEYUGU-cf0c5e69-620c-4f3c-84ab-f4619262939f/49b773a3-273f-4b1c-95e8-a42dcba1a53c.png) +## 1.3.4(2022-05-03) +* 【修复】`u-tabs` 组件细节问题。 +## 1.1.4(2022-03-22) +* 【修复】`u-field` 组件 `arrowDirection` 属性无效的问题。 +## 1.1.3(2022-03-21) +* 【优化】部分细节。 +## 1.1.2(2022-03-21) +* 【优化】部分细节。 +## 1.1.1(2022-03-17) +* 【优化】部分细节。 +## 1.1.0(2022-03-12) +* 【重要】`u-picker` 组件新增 `regionDiscern` 方法 智能识别省市区街道地址 +如将字符串 `浙江省杭州市西湖区希望路1333弄是啊我庭12号楼1203` 中识别为 +```json +{ + "province": { + "code": "330000", + "name": "浙江省" + }, + "city": { + "code": "330100", + "name": "杭州市" + }, + "area": { + "code": "330106", + "name": "西湖区" + }, + "address": "龙井路1号", + "formatted_address": "浙江省杭州市西湖区龙井路1号" +} +``` +而组件的 `addressDiscern` 方法还可以识别收货信息,如 `张三 13888888888 上海市嘉定区希望路1333弄是啊我庭12号楼1203` 中识别姓名、手机号、地址(支持多种格式) +## 1.0.13(2022-03-12) +* 【优化】部分细节。 +## 1.0.12(2022-03-09) +* 【修复】`u-radio-group` 在 vue3 模式下,设置默认值可能会无效的问题。 +## 1.0.11(2022-03-07) +* 【优化】部分细节。 +## 1.0.10(2022-03-05) +* 【修复】`u-radio` 中的值相等的判断 == 改为 === +* 【优化】部分注释的错别字。 +## 1.0.9(2022-03-03) +* 【修复】`u-parse` 在 vue3模式下编译到app无法正常显示的问题。 +## 1.0.8(2022-02-26) +* 【优化】`u-form` 组件新增2个属性 `inputAlign` 和 `clearable` 用于统一设置表单内所有 `u-input` 组件的对应属性默认值 +* 【优化】更新城市数据源信息 +## 1.0.7(2022-02-25) +* 【重要】`u-picker` 组件新增 `addressDiscern` 方法 智能识别收货信息 + +如在 `张三 13888888888 上海市嘉定区希望路1333弄是啊我庭12号楼1203` 中识别姓名、手机号、地址(支持多种格式) +即使这样的字符串也能识别 `!!!!~~~$张三~~~上海市嘉定区希望路1333弄是啊我庭12号楼1203【【【【13888888888】` +## 1.0.6(2022-02-24) +* 【优化】`u-form-item` 组件的 `prop` 属性支持 a.b 形式 +## 1.0.5(2022-01-11) +* 【修复】`u-sticky` 组件 在微信小程序中无法正常吸顶的问题 +## 1.0.4(2021-12-31) +* 【优化】`u-dropdown-item` 组件 0和"" 无法区分的问题。 +* 【修复】`u-modal` 在Vue3版本中使用了mask-close-able属性无效的问题 +## 1.0.3(2021-12-20) +【优化】u-icon在微信小程序下可能会显示null字符串的问题 +## 1.0.2(2021-12-09) +* 1、【优化】`u-button` 组件新增 `timerId` 属性 +* 之前的效果是:所有按钮一定时间内只能点击1次(`共用计算时间`)导致点击按钮A后无法马上点击按钮B +* 优化的效果是:每个按钮一定时间内只能点击1次(`分开计算时间`)且支持设置相同的 timerId 来达到指定按钮 `共用计算时间` +## 1.0.1(2021-11-22) +* 修复 u-parse 组件在微信小程序上的显示问题。 +## 1.0.0(2021-11-18) +uView Vue3.0 横空出世,继承uView1.0意志,再战江湖,风云再起!by vk 2021-11-18 diff --git a/src/uni_modules/vk-uview-ui/components/u-action-sheet/u-action-sheet.vue b/src/uni_modules/vk-uview-ui/components/u-action-sheet/u-action-sheet.vue new file mode 100644 index 0000000..c5261a1 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-action-sheet/u-action-sheet.vue @@ -0,0 +1,246 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-alert-tips/u-alert-tips.vue b/src/uni_modules/vk-uview-ui/components/u-alert-tips/u-alert-tips.vue new file mode 100644 index 0000000..48b3d85 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-alert-tips/u-alert-tips.vue @@ -0,0 +1,257 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-avatar-cropper/u-avatar-cropper.vue b/src/uni_modules/vk-uview-ui/components/u-avatar-cropper/u-avatar-cropper.vue new file mode 100644 index 0000000..a48dd54 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-avatar-cropper/u-avatar-cropper.vue @@ -0,0 +1,290 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-avatar-cropper/weCropper.js b/src/uni_modules/vk-uview-ui/components/u-avatar-cropper/weCropper.js new file mode 100644 index 0000000..3337cf1 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-avatar-cropper/weCropper.js @@ -0,0 +1,1261 @@ +/** + * we-cropper v1.3.9 + * (c) 2020 dlhandsome + * @license MIT + */ + + 'use strict'; + + var device = void 0; + var TOUCH_STATE = ['touchstarted', 'touchmoved', 'touchended']; + + function firstLetterUpper(str) { + return str.charAt(0).toUpperCase() + str.slice(1) + } + + function setTouchState(instance) { + var arg = [], + len = arguments.length - 1; + while (len-- > 0) arg[len] = arguments[len + 1]; + + TOUCH_STATE.forEach(function(key, i) { + if (arg[i] !== undefined) { + instance[key] = arg[i]; + } + }); + } + + function validator(instance, o) { + Object.defineProperties(instance, o); + } + + function getDevice() { + if (!device) { + device = uni.getSystemInfoSync(); + } + return device + } + + var tmp = {}; + + var ref = getDevice(); + var pixelRatio = ref.pixelRatio; + + var DEFAULT = { + id: { + default: 'cropper', + get: function get() { + return tmp.id + }, + set: function set(value) { + if (typeof(value) !== 'string') { + console.error(("id:" + value + " is invalid")); + } + tmp.id = value; + } + }, + width: { + default: 750, + get: function get() { + return tmp.width + }, + set: function set(value) { + if (typeof(value) !== 'number') { + console.error(("width:" + value + " is invalid")); + } + tmp.width = value; + } + }, + height: { + default: 750, + get: function get() { + return tmp.height + }, + set: function set(value) { + if (typeof(value) !== 'number') { + console.error(("height:" + value + " is invalid")); + } + tmp.height = value; + } + }, + pixelRatio: { + default: pixelRatio, + get: function get() { + return tmp.pixelRatio + }, + set: function set(value) { + if (typeof(value) !== 'number') { + console.error(("pixelRatio:" + value + " is invalid")); + } + tmp.pixelRatio = value; + } + }, + scale: { + default: 2.5, + get: function get() { + return tmp.scale + }, + set: function set(value) { + if (typeof(value) !== 'number') { + console.error(("scale:" + value + " is invalid")); + } + tmp.scale = value; + } + }, + zoom: { + default: 5, + get: function get() { + return tmp.zoom + }, + set: function set(value) { + if (typeof(value) !== 'number') { + console.error(("zoom:" + value + " is invalid")); + } else if (value < 0 || value > 10) { + console.error("zoom should be ranged in 0 ~ 10"); + } + tmp.zoom = value; + } + }, + src: { + default: '', + get: function get() { + return tmp.src + }, + set: function set(value) { + if (typeof(value) !== 'string') { + console.error(("src:" + value + " is invalid")); + } + tmp.src = value; + } + }, + cut: { + default: {}, + get: function get() { + return tmp.cut + }, + set: function set(value) { + if (typeof(value) !== 'object') { + console.error(("cut:" + value + " is invalid")); + } + tmp.cut = value; + } + }, + boundStyle: { + default: {}, + get: function get() { + return tmp.boundStyle + }, + set: function set(value) { + if (typeof(value) !== 'object') { + console.error(("boundStyle:" + value + " is invalid")); + } + tmp.boundStyle = value; + } + }, + onReady: { + default: null, + get: function get() { + return tmp.ready + }, + set: function set(value) { + tmp.ready = value; + } + }, + onBeforeImageLoad: { + default: null, + get: function get() { + return tmp.beforeImageLoad + }, + set: function set(value) { + tmp.beforeImageLoad = value; + } + }, + onImageLoad: { + default: null, + get: function get() { + return tmp.imageLoad + }, + set: function set(value) { + tmp.imageLoad = value; + } + }, + onBeforeDraw: { + default: null, + get: function get() { + return tmp.beforeDraw + }, + set: function set(value) { + tmp.beforeDraw = value; + } + } + }; + + var ref$1 = getDevice(); + var windowWidth = ref$1.windowWidth; + + function prepare() { + var self = this; + + // v1.4.0 版本中将不再自动绑定we-cropper实例 + self.attachPage = function() { + var pages = getCurrentPages(); + // 获取到当前page上下文 + var pageContext = pages[pages.length - 1]; + // 把this依附在Page上下文的wecropper属性上,便于在page钩子函数中访问 + Object.defineProperty(pageContext, 'wecropper', { + get: function get() { + console.warn( + 'Instance will not be automatically bound to the page after v1.4.0\n\n' + + 'Please use a custom instance name instead\n\n' + + 'Example: \n' + + 'this.mycropper = new WeCropper(options)\n\n' + + '// ...\n' + + 'this.mycropper.getCropperImage()' + ); + return self + }, + configurable: true + }); + }; + + self.createCtx = function() { + var id = self.id; + var targetId = self.targetId; + + if (id) { + self.ctx = self.ctx || uni.createCanvasContext(id); + self.targetCtx = self.targetCtx || uni.createCanvasContext(targetId); + } else { + console.error("constructor: create canvas context failed, 'id' must be valuable"); + } + }; + + self.deviceRadio = windowWidth / 750; + } + + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== + 'undefined' ? self : {}; + + + + + + function createCommonjsModule(fn, module) { + return module = { + exports: {} + }, fn(module, module.exports), module.exports; + } + + var tools = createCommonjsModule(function(module, exports) { + /** + * String type check + */ + exports.isStr = function(v) { + return typeof v === 'string'; + }; + /** + * Number type check + */ + exports.isNum = function(v) { + return typeof v === 'number'; + }; + /** + * Array type check + */ + exports.isArr = Array.isArray; + /** + * undefined type check + */ + exports.isUndef = function(v) { + return v === undefined; + }; + + exports.isTrue = function(v) { + return v === true; + }; + + exports.isFalse = function(v) { + return v === false; + }; + /** + * Function type check + */ + exports.isFunc = function(v) { + return typeof v === 'function'; + }; + /** + * Quick object check - this is primarily used to tell + * Objects from primitive values when we know the value + * is a JSON-compliant type. + */ + exports.isObj = exports.isObject = function(obj) { + return obj !== null && typeof obj === 'object' + }; + + /** + * Strict object type check. Only returns true + * for plain JavaScript objects. + */ + var _toString = Object.prototype.toString; + exports.isPlainObject = function(obj) { + return _toString.call(obj) === '[object Object]' + }; + + /** + * Check whether the object has the property. + */ + var hasOwnProperty = Object.prototype.hasOwnProperty; + exports.hasOwn = function(obj, key) { + return hasOwnProperty.call(obj, key) + }; + + /** + * Perform no operation. + * Stubbing args to make Flow happy without leaving useless transpiled code + * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/) + */ + exports.noop = function(a, b, c) {}; + + /** + * Check if val is a valid array index. + */ + exports.isValidArrayIndex = function(val) { + var n = parseFloat(String(val)); + return n >= 0 && Math.floor(n) === n && isFinite(val) + }; + }); + + var tools_7 = tools.isFunc; + var tools_10 = tools.isPlainObject; + + var EVENT_TYPE = ['ready', 'beforeImageLoad', 'beforeDraw', 'imageLoad']; + + function observer() { + var self = this; + + self.on = function(event, fn) { + if (EVENT_TYPE.indexOf(event) > -1) { + if (tools_7(fn)) { + event === 'ready' ? + fn(self) : + self[("on" + (firstLetterUpper(event)))] = fn; + } + } else { + console.error(("event: " + event + " is invalid")); + } + return self + }; + } + + function wxPromise(fn) { + return function(obj) { + var args = [], + len = arguments.length - 1; + while (len-- > 0) args[len] = arguments[len + 1]; + + if (obj === void 0) obj = {}; + return new Promise(function(resolve, reject) { + obj.success = function(res) { + resolve(res); + }; + obj.fail = function(err) { + reject(err); + }; + fn.apply(void 0, [obj].concat(args)); + }) + } + } + + function draw(ctx, reserve) { + if (reserve === void 0) reserve = false; + + return new Promise(function(resolve) { + ctx.draw(reserve, resolve); + }) + } + + var getImageInfo = wxPromise(uni.getImageInfo); + + var canvasToTempFilePath = wxPromise(uni.canvasToTempFilePath); + + var base64 = createCommonjsModule(function(module, exports) { + /*! http://mths.be/base64 v0.1.0 by @mathias | MIT license */ + (function(root) { + + // Detect free variables `exports`. + var freeExports = 'object' == 'object' && exports; + + // Detect free variable `module`. + var freeModule = 'object' == 'object' && module && + module.exports == freeExports && module; + + // Detect free variable `global`, from Node.js or Browserified code, and use + // it as `root`. + var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal; + if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { + root = freeGlobal; + } + + /*--------------------------------------------------------------------------*/ + + var InvalidCharacterError = function(message) { + this.message = message; + }; + InvalidCharacterError.prototype = new Error; + InvalidCharacterError.prototype.name = 'InvalidCharacterError'; + + var error = function(message) { + // Note: the error messages used throughout this file match those used by + // the native `atob`/`btoa` implementation in Chromium. + throw new InvalidCharacterError(message); + }; + + var TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + // http://whatwg.org/html/common-microsyntaxes.html#space-character + var REGEX_SPACE_CHARACTERS = /[\t\n\f\r ]/g; + + // `decode` is designed to be fully compatible with `atob` as described in the + // HTML Standard. http://whatwg.org/html/webappapis.html#dom-windowbase64-atob + // The optimized base64-decoding algorithm used is based on @atk’s excellent + // implementation. https://gist.github.com/atk/1020396 + var decode = function(input) { + input = String(input) + .replace(REGEX_SPACE_CHARACTERS, ''); + var length = input.length; + if (length % 4 == 0) { + input = input.replace(/==?$/, ''); + length = input.length; + } + if ( + length % 4 == 1 || + // http://whatwg.org/C#alphanumeric-ascii-characters + /[^+a-zA-Z0-9/]/.test(input) + ) { + error( + 'Invalid character: the string to be decoded is not correctly encoded.' + ); + } + var bitCounter = 0; + var bitStorage; + var buffer; + var output = ''; + var position = -1; + while (++position < length) { + buffer = TABLE.indexOf(input.charAt(position)); + bitStorage = bitCounter % 4 ? bitStorage * 64 + buffer : buffer; + // Unless this is the first of a group of 4 characters… + if (bitCounter++ % 4) { + // …convert the first 8 bits to a single ASCII character. + output += String.fromCharCode( + 0xFF & bitStorage >> (-2 * bitCounter & 6) + ); + } + } + return output; + }; + + // `encode` is designed to be fully compatible with `btoa` as described in the + // HTML Standard: http://whatwg.org/html/webappapis.html#dom-windowbase64-btoa + var encode = function(input) { + input = String(input); + if (/[^\0-\xFF]/.test(input)) { + // Note: no need to special-case astral symbols here, as surrogates are + // matched, and the input is supposed to only contain ASCII anyway. + error( + 'The string to be encoded contains characters outside of the ' + + 'Latin1 range.' + ); + } + var padding = input.length % 3; + var output = ''; + var position = -1; + var a; + var b; + var c; + var buffer; + // Make sure any padding is handled outside of the loop. + var length = input.length - padding; + + while (++position < length) { + // Read three bytes, i.e. 24 bits. + a = input.charCodeAt(position) << 16; + b = input.charCodeAt(++position) << 8; + c = input.charCodeAt(++position); + buffer = a + b + c; + // Turn the 24 bits into four chunks of 6 bits each, and append the + // matching character for each of them to the output. + output += ( + TABLE.charAt(buffer >> 18 & 0x3F) + + TABLE.charAt(buffer >> 12 & 0x3F) + + TABLE.charAt(buffer >> 6 & 0x3F) + + TABLE.charAt(buffer & 0x3F) + ); + } + + if (padding == 2) { + a = input.charCodeAt(position) << 8; + b = input.charCodeAt(++position); + buffer = a + b; + output += ( + TABLE.charAt(buffer >> 10) + + TABLE.charAt((buffer >> 4) & 0x3F) + + TABLE.charAt((buffer << 2) & 0x3F) + + '=' + ); + } else if (padding == 1) { + buffer = input.charCodeAt(position); + output += ( + TABLE.charAt(buffer >> 2) + + TABLE.charAt((buffer << 4) & 0x3F) + + '==' + ); + } + + return output; + }; + + var base64 = { + 'encode': encode, + 'decode': decode, + 'version': '0.1.0' + }; + + // Some AMD build optimizers, like r.js, check for specific condition patterns + // like the following: + if ( + typeof undefined == 'function' && + typeof undefined.amd == 'object' && + undefined.amd + ) { + undefined(function() { + return base64; + }); + } else if (freeExports && !freeExports.nodeType) { + if (freeModule) { // in Node.js or RingoJS v0.8.0+ + freeModule.exports = base64; + } else { // in Narwhal or RingoJS v0.7.0- + for (var key in base64) { + base64.hasOwnProperty(key) && (freeExports[key] = base64[key]); + } + } + } else { // in Rhino or a web browser + root.base64 = base64; + } + + }(commonjsGlobal)); + }); + + function makeURI(strData, type) { + return 'data:' + type + ';base64,' + strData + } + + function fixType(type) { + type = type.toLowerCase().replace(/jpg/i, 'jpeg'); + var r = type.match(/png|jpeg|bmp|gif/)[0]; + return 'image/' + r + } + + function encodeData(data) { + var str = ''; + if (typeof data === 'string') { + str = data; + } else { + for (var i = 0; i < data.length; i++) { + str += String.fromCharCode(data[i]); + } + } + return base64.encode(str) + } + + /** + * 获取图像区域隐含的像素数据 + * @param canvasId canvas标识 + * @param x 将要被提取的图像数据矩形区域的左上角 x 坐标 + * @param y 将要被提取的图像数据矩形区域的左上角 y 坐标 + * @param width 将要被提取的图像数据矩形区域的宽度 + * @param height 将要被提取的图像数据矩形区域的高度 + * @param done 完成回调 + */ + function getImageData(canvasId, x, y, width, height, done) { + uni.canvasGetImageData({ + canvasId: canvasId, + x: x, + y: y, + width: width, + height: height, + success: function success(res) { + done(res, null); + }, + fail: function fail(res) { + done(null, res); + } + }); + } + + /** + * 生成bmp格式图片 + * 按照规则生成图片响应头和响应体 + * @param oData 用来描述 canvas 区域隐含的像素数据 { data, width, height } = oData + * @returns {*} base64字符串 + */ + function genBitmapImage(oData) { + // + // BITMAPFILEHEADER: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183374(v=vs.85).aspx + // BITMAPINFOHEADER: http://msdn.microsoft.com/en-us/library/dd183376.aspx + // + var biWidth = oData.width; + var biHeight = oData.height; + var biSizeImage = biWidth * biHeight * 3; + var bfSize = biSizeImage + 54; // total header size = 54 bytes + + // + // typedef struct tagBITMAPFILEHEADER { + // WORD bfType; + // DWORD bfSize; + // WORD bfReserved1; + // WORD bfReserved2; + // DWORD bfOffBits; + // } BITMAPFILEHEADER; + // + var BITMAPFILEHEADER = [ + // WORD bfType -- The file type signature; must be "BM" + 0x42, 0x4D, + // DWORD bfSize -- The size, in bytes, of the bitmap file + bfSize & 0xff, bfSize >> 8 & 0xff, bfSize >> 16 & 0xff, bfSize >> 24 & 0xff, + // WORD bfReserved1 -- Reserved; must be zero + 0, 0, + // WORD bfReserved2 -- Reserved; must be zero + 0, 0, + // DWORD bfOffBits -- The offset, in bytes, from the beginning of the BITMAPFILEHEADER structure to the bitmap bits. + 54, 0, 0, 0 + ]; + + // + // typedef struct tagBITMAPINFOHEADER { + // DWORD biSize; + // LONG biWidth; + // LONG biHeight; + // WORD biPlanes; + // WORD biBitCount; + // DWORD biCompression; + // DWORD biSizeImage; + // LONG biXPelsPerMeter; + // LONG biYPelsPerMeter; + // DWORD biClrUsed; + // DWORD biClrImportant; + // } BITMAPINFOHEADER, *PBITMAPINFOHEADER; + // + var BITMAPINFOHEADER = [ + // DWORD biSize -- The number of bytes required by the structure + 40, 0, 0, 0, + // LONG biWidth -- The width of the bitmap, in pixels + biWidth & 0xff, biWidth >> 8 & 0xff, biWidth >> 16 & 0xff, biWidth >> 24 & 0xff, + // LONG biHeight -- The height of the bitmap, in pixels + biHeight & 0xff, biHeight >> 8 & 0xff, biHeight >> 16 & 0xff, biHeight >> 24 & 0xff, + // WORD biPlanes -- The number of planes for the target device. This value must be set to 1 + 1, 0, + // WORD biBitCount -- The number of bits-per-pixel, 24 bits-per-pixel -- the bitmap + // has a maximum of 2^24 colors (16777216, Truecolor) + 24, 0, + // DWORD biCompression -- The type of compression, BI_RGB (code 0) -- uncompressed + 0, 0, 0, 0, + // DWORD biSizeImage -- The size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps + biSizeImage & 0xff, biSizeImage >> 8 & 0xff, biSizeImage >> 16 & 0xff, biSizeImage >> 24 & 0xff, + // LONG biXPelsPerMeter, unused + 0, 0, 0, 0, + // LONG biYPelsPerMeter, unused + 0, 0, 0, 0, + // DWORD biClrUsed, the number of color indexes of palette, unused + 0, 0, 0, 0, + // DWORD biClrImportant, unused + 0, 0, 0, 0 + ]; + + var iPadding = (4 - ((biWidth * 3) % 4)) % 4; + + var aImgData = oData.data; + + var strPixelData = ''; + var biWidth4 = biWidth << 2; + var y = biHeight; + var fromCharCode = String.fromCharCode; + + do { + var iOffsetY = biWidth4 * (y - 1); + var strPixelRow = ''; + for (var x = 0; x < biWidth; x++) { + var iOffsetX = x << 2; + strPixelRow += fromCharCode(aImgData[iOffsetY + iOffsetX + 2]) + + fromCharCode(aImgData[iOffsetY + iOffsetX + 1]) + + fromCharCode(aImgData[iOffsetY + iOffsetX]); + } + + for (var c = 0; c < iPadding; c++) { + strPixelRow += String.fromCharCode(0); + } + + strPixelData += strPixelRow; + } while (--y) + + var strEncoded = encodeData(BITMAPFILEHEADER.concat(BITMAPINFOHEADER)) + encodeData(strPixelData); + + return strEncoded + } + + /** + * 转换为图片base64 + * @param canvasId canvas标识 + * @param x 将要被提取的图像数据矩形区域的左上角 x 坐标 + * @param y 将要被提取的图像数据矩形区域的左上角 y 坐标 + * @param width 将要被提取的图像数据矩形区域的宽度 + * @param height 将要被提取的图像数据矩形区域的高度 + * @param type 转换图片类型 + * @param done 完成回调 + */ + function convertToImage(canvasId, x, y, width, height, type, done) { + if (done === void 0) done = function() {}; + + if (type === undefined) { + type = 'png'; + } + type = fixType(type); + if (/bmp/.test(type)) { + getImageData(canvasId, x, y, width, height, function(data, err) { + var strData = genBitmapImage(data); + tools_7(done) && done(makeURI(strData, 'image/' + type), err); + }); + } else { + console.error('暂不支持生成\'' + type + '\'类型的base64图片'); + } + } + + var CanvasToBase64 = { + convertToImage: convertToImage, + // convertToPNG: function (width, height, done) { + // return convertToImage(width, height, 'png', done) + // }, + // convertToJPEG: function (width, height, done) { + // return convertToImage(width, height, 'jpeg', done) + // }, + // convertToGIF: function (width, height, done) { + // return convertToImage(width, height, 'gif', done) + // }, + convertToBMP: function(ref, done) { + if (ref === void 0) ref = {}; + var canvasId = ref.canvasId; + var x = ref.x; + var y = ref.y; + var width = ref.width; + var height = ref.height; + if (done === void 0) done = function() {}; + + return convertToImage(canvasId, x, y, width, height, 'bmp', done) + } + }; + + function methods() { + var self = this; + + var boundWidth = self.width; // 裁剪框默认宽度,即整个画布宽度 + var boundHeight = self.height; // 裁剪框默认高度,即整个画布高度 + + var id = self.id; + var targetId = self.targetId; + var pixelRatio = self.pixelRatio; + + var ref = self.cut; + var x = ref.x; + if (x === void 0) x = 0; + var y = ref.y; + if (y === void 0) y = 0; + var width = ref.width; + if (width === void 0) width = boundWidth; + var height = ref.height; + if (height === void 0) height = boundHeight; + + self.updateCanvas = function(done) { + if (self.croperTarget) { + // 画布绘制图片 + self.ctx.drawImage( + self.croperTarget, + self.imgLeft, + self.imgTop, + self.scaleWidth, + self.scaleHeight + ); + } + tools_7(self.onBeforeDraw) && self.onBeforeDraw(self.ctx, self); + + self.setBoundStyle(self.boundStyle); // 设置边界样式 + + self.ctx.draw(false, done); + return self + }; + + self.pushOrigin = self.pushOrign = function(src) { + self.src = src; + + tools_7(self.onBeforeImageLoad) && self.onBeforeImageLoad(self.ctx, self); + + return getImageInfo({ + src: src + }) + .then(function(res) { + var innerAspectRadio = res.width / res.height; + var customAspectRadio = width / height; + + self.croperTarget = res.path; + + if (innerAspectRadio < customAspectRadio) { + self.rectX = x; + self.baseWidth = width; + self.baseHeight = width / innerAspectRadio; + self.rectY = y - Math.abs((height - self.baseHeight) / 2); + } else { + self.rectY = y; + self.baseWidth = height * innerAspectRadio; + self.baseHeight = height; + self.rectX = x - Math.abs((width - self.baseWidth) / 2); + } + + self.imgLeft = self.rectX; + self.imgTop = self.rectY; + self.scaleWidth = self.baseWidth; + self.scaleHeight = self.baseHeight; + + self.update(); + + return new Promise(function(resolve) { + self.updateCanvas(resolve); + }) + }) + .then(function() { + tools_7(self.onImageLoad) && self.onImageLoad(self.ctx, self); + }) + }; + + self.removeImage = function() { + self.src = ''; + self.croperTarget = ''; + return draw(self.ctx) + }; + + self.getCropperBase64 = function(done) { + if (done === void 0) done = function() {}; + + CanvasToBase64.convertToBMP({ + canvasId: id, + x: x, + y: y, + width: width, + height: height + }, done); + }; + + self.getCropperImage = function(opt, fn) { + var customOptions = opt; + + var canvasOptions = { + canvasId: id, + x: x, + y: y, + width: width, + height: height + }; + + var task = function() { + return Promise.resolve(); + }; + + if ( + tools_10(customOptions) && + customOptions.original + ) { + // original mode + task = function() { + self.targetCtx.drawImage( + self.croperTarget, + self.imgLeft * pixelRatio, + self.imgTop * pixelRatio, + self.scaleWidth * pixelRatio, + self.scaleHeight * pixelRatio + ); + + canvasOptions = { + canvasId: targetId, + x: x * pixelRatio, + y: y * pixelRatio, + width: width * pixelRatio, + height: height * pixelRatio + }; + + return draw(self.targetCtx) + }; + } + + return task() + .then(function() { + if (tools_10(customOptions)) { + canvasOptions = Object.assign({}, canvasOptions, customOptions); + } + + if (tools_7(customOptions)) { + fn = customOptions; + } + + var arg = canvasOptions.componentContext ? + [canvasOptions, canvasOptions.componentContext] : + [canvasOptions]; + + return canvasToTempFilePath.apply(null, arg) + }) + .then(function(res) { + var tempFilePath = res.tempFilePath; + + return tools_7(fn) ? + fn.call(self, tempFilePath, null) : + tempFilePath + }) + .catch(function(err) { + if (tools_7(fn)) { + fn.call(self, null, err); + } else { + throw err + } + }) + }; + } + + /** + * 获取最新缩放值 + * @param oldScale 上一次触摸结束后的缩放值 + * @param oldDistance 上一次触摸结束后的双指距离 + * @param zoom 缩放系数 + * @param touch0 第一指touch对象 + * @param touch1 第二指touch对象 + * @returns {*} + */ + var getNewScale = function(oldScale, oldDistance, zoom, touch0, touch1) { + var xMove, yMove, newDistance; + // 计算二指最新距离 + xMove = Math.round(touch1.x - touch0.x); + yMove = Math.round(touch1.y - touch0.y); + newDistance = Math.round(Math.sqrt(xMove * xMove + yMove * yMove)); + + return oldScale + 0.001 * zoom * (newDistance - oldDistance) + }; + + function update() { + var self = this; + + if (!self.src) { + return + } + + self.__oneTouchStart = function(touch) { + self.touchX0 = Math.round(touch.x); + self.touchY0 = Math.round(touch.y); + }; + + self.__oneTouchMove = function(touch) { + var xMove, yMove; + // 计算单指移动的距离 + if (self.touchended) { + return self.updateCanvas() + } + xMove = Math.round(touch.x - self.touchX0); + yMove = Math.round(touch.y - self.touchY0); + + var imgLeft = Math.round(self.rectX + xMove); + var imgTop = Math.round(self.rectY + yMove); + + self.outsideBound(imgLeft, imgTop); + + self.updateCanvas(); + }; + + self.__twoTouchStart = function(touch0, touch1) { + var xMove, yMove, oldDistance; + + self.touchX1 = Math.round(self.rectX + self.scaleWidth / 2); + self.touchY1 = Math.round(self.rectY + self.scaleHeight / 2); + + // 计算两指距离 + xMove = Math.round(touch1.x - touch0.x); + yMove = Math.round(touch1.y - touch0.y); + oldDistance = Math.round(Math.sqrt(xMove * xMove + yMove * yMove)); + + self.oldDistance = oldDistance; + }; + + self.__twoTouchMove = function(touch0, touch1) { + var oldScale = self.oldScale; + var oldDistance = self.oldDistance; + var scale = self.scale; + var zoom = self.zoom; + + self.newScale = getNewScale(oldScale, oldDistance, zoom, touch0, touch1); + + // 设定缩放范围 + self.newScale <= 1 && (self.newScale = 1); + self.newScale >= scale && (self.newScale = scale); + + self.scaleWidth = Math.round(self.newScale * self.baseWidth); + self.scaleHeight = Math.round(self.newScale * self.baseHeight); + var imgLeft = Math.round(self.touchX1 - self.scaleWidth / 2); + var imgTop = Math.round(self.touchY1 - self.scaleHeight / 2); + + self.outsideBound(imgLeft, imgTop); + + self.updateCanvas(); + }; + + self.__xtouchEnd = function() { + self.oldScale = self.newScale; + self.rectX = self.imgLeft; + self.rectY = self.imgTop; + }; + } + + var handle = { + // 图片手势初始监测 + touchStart: function touchStart(e) { + var self = this; + var ref = e.touches; + var touch0 = ref[0]; + var touch1 = ref[1]; + + if (!self.src) { + return + } + + setTouchState(self, true, null, null); + + // 计算第一个触摸点的位置,并参照改点进行缩放 + self.__oneTouchStart(touch0); + + // 两指手势触发 + if (e.touches.length >= 2) { + self.__twoTouchStart(touch0, touch1); + } + }, + + // 图片手势动态缩放 + touchMove: function touchMove(e) { + var self = this; + var ref = e.touches; + var touch0 = ref[0]; + var touch1 = ref[1]; + + if (!self.src) { + return + } + + setTouchState(self, null, true); + + // 单指手势时触发 + if (e.touches.length === 1) { + self.__oneTouchMove(touch0); + } + // 两指手势触发 + if (e.touches.length >= 2) { + self.__twoTouchMove(touch0, touch1); + } + }, + + touchEnd: function touchEnd(e) { + var self = this; + + if (!self.src) { + return + } + + setTouchState(self, false, false, true); + self.__xtouchEnd(); + } + }; + + function cut() { + var self = this; + var boundWidth = self.width; // 裁剪框默认宽度,即整个画布宽度 + var boundHeight = self.height; + // 裁剪框默认高度,即整个画布高度 + var ref = self.cut; + var x = ref.x; + if (x === void 0) x = 0; + var y = ref.y; + if (y === void 0) y = 0; + var width = ref.width; + if (width === void 0) width = boundWidth; + var height = ref.height; + if (height === void 0) height = boundHeight; + + /** + * 设置边界 + * @param imgLeft 图片左上角横坐标值 + * @param imgTop 图片左上角纵坐标值 + */ + self.outsideBound = function(imgLeft, imgTop) { + self.imgLeft = imgLeft >= x ? + x : + self.scaleWidth + imgLeft - x <= width ? + x + width - self.scaleWidth : + imgLeft; + + self.imgTop = imgTop >= y ? + y : + self.scaleHeight + imgTop - y <= height ? + y + height - self.scaleHeight : + imgTop; + }; + + /** + * 设置边界样式 + * @param color 边界颜色 + */ + self.setBoundStyle = function(ref) { + if (ref === void 0) ref = {}; + var color = ref.color; + if (color === void 0) color = '#04b00f'; + var mask = ref.mask; + if (mask === void 0) mask = 'rgba(0, 0, 0, 0.3)'; + var lineWidth = ref.lineWidth; + if (lineWidth === void 0) lineWidth = 1; + + var half = lineWidth / 2; + var boundOption = [{ + start: { + x: x - half, + y: y + 10 - half + }, + step1: { + x: x - half, + y: y - half + }, + step2: { + x: x + 10 - half, + y: y - half + } + }, + { + start: { + x: x - half, + y: y + height - 10 + half + }, + step1: { + x: x - half, + y: y + height + half + }, + step2: { + x: x + 10 - half, + y: y + height + half + } + }, + { + start: { + x: x + width - 10 + half, + y: y - half + }, + step1: { + x: x + width + half, + y: y - half + }, + step2: { + x: x + width + half, + y: y + 10 - half + } + }, + { + start: { + x: x + width + half, + y: y + height - 10 + half + }, + step1: { + x: x + width + half, + y: y + height + half + }, + step2: { + x: x + width - 10 + half, + y: y + height + half + } + } + ]; + + // 绘制半透明层 + self.ctx.beginPath(); + self.ctx.setFillStyle(mask); + self.ctx.fillRect(0, 0, x, boundHeight); + self.ctx.fillRect(x, 0, width, y); + self.ctx.fillRect(x, y + height, width, boundHeight - y - height); + self.ctx.fillRect(x + width, 0, boundWidth - x - width, boundHeight); + self.ctx.fill(); + + boundOption.forEach(function(op) { + self.ctx.beginPath(); + self.ctx.setStrokeStyle(color); + self.ctx.setLineWidth(lineWidth); + self.ctx.moveTo(op.start.x, op.start.y); + self.ctx.lineTo(op.step1.x, op.step1.y); + self.ctx.lineTo(op.step2.x, op.step2.y); + self.ctx.stroke(); + }); + }; + } + + var version = "1.3.9"; + + var WeCropper = function WeCropper(params) { + var self = this; + var _default = {}; + + validator(self, DEFAULT); + + Object.keys(DEFAULT).forEach(function(key) { + _default[key] = DEFAULT[key].default; + }); + Object.assign(self, _default, params); + + self.prepare(); + self.attachPage(); + self.createCtx(); + self.observer(); + self.cutt(); + self.methods(); + self.init(); + self.update(); + + return self + }; + + WeCropper.prototype.init = function init() { + var self = this; + var src = self.src; + + self.version = version; + + typeof self.onReady === 'function' && self.onReady(self.ctx, self); + + if (src) { + self.pushOrign(src); + } else { + self.updateCanvas(); + } + setTouchState(self, false, false, false); + + self.oldScale = 1; + self.newScale = 1; + + return self + }; + + Object.assign(WeCropper.prototype, handle); + + WeCropper.prototype.prepare = prepare; + WeCropper.prototype.observer = observer; + WeCropper.prototype.methods = methods; + WeCropper.prototype.cutt = cut; + WeCropper.prototype.update = update; + + export default WeCropper + + diff --git a/src/uni_modules/vk-uview-ui/components/u-avatar/u-avatar.vue b/src/uni_modules/vk-uview-ui/components/u-avatar/u-avatar.vue new file mode 100644 index 0000000..ab21c46 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-avatar/u-avatar.vue @@ -0,0 +1,263 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-back-top/u-back-top.vue b/src/uni_modules/vk-uview-ui/components/u-back-top/u-back-top.vue new file mode 100644 index 0000000..7970fc7 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-back-top/u-back-top.vue @@ -0,0 +1,153 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-badge/u-badge.vue b/src/uni_modules/vk-uview-ui/components/u-badge/u-badge.vue new file mode 100644 index 0000000..e85b133 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-badge/u-badge.vue @@ -0,0 +1,216 @@ + + + + + \ No newline at end of file diff --git a/src/uni_modules/vk-uview-ui/components/u-button/u-button.vue b/src/uni_modules/vk-uview-ui/components/u-button/u-button.vue new file mode 100644 index 0000000..2647afc --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-button/u-button.vue @@ -0,0 +1,602 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-calendar/u-calendar.vue b/src/uni_modules/vk-uview-ui/components/u-calendar/u-calendar.vue new file mode 100644 index 0000000..cb7f3e8 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-calendar/u-calendar.vue @@ -0,0 +1,663 @@ + + + + \ No newline at end of file diff --git a/src/uni_modules/vk-uview-ui/components/u-car-keyboard/u-car-keyboard.vue b/src/uni_modules/vk-uview-ui/components/u-car-keyboard/u-car-keyboard.vue new file mode 100644 index 0000000..e55db26 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-car-keyboard/u-car-keyboard.vue @@ -0,0 +1,267 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-card/u-card.vue b/src/uni_modules/vk-uview-ui/components/u-card/u-card.vue new file mode 100644 index 0000000..b4ad301 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-card/u-card.vue @@ -0,0 +1,300 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-cell-group/u-cell-group.vue b/src/uni_modules/vk-uview-ui/components/u-cell-group/u-cell-group.vue new file mode 100644 index 0000000..3fbca72 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-cell-group/u-cell-group.vue @@ -0,0 +1,70 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-cell-item/u-cell-item.vue b/src/uni_modules/vk-uview-ui/components/u-cell-item/u-cell-item.vue new file mode 100644 index 0000000..90ee117 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-cell-item/u-cell-item.vue @@ -0,0 +1,317 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-checkbox-group/u-checkbox-group.vue b/src/uni_modules/vk-uview-ui/components/u-checkbox-group/u-checkbox-group.vue new file mode 100644 index 0000000..18c39e7 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-checkbox-group/u-checkbox-group.vue @@ -0,0 +1,178 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-checkbox/u-checkbox.vue b/src/uni_modules/vk-uview-ui/components/u-checkbox/u-checkbox.vue new file mode 100644 index 0000000..a0498fe --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-checkbox/u-checkbox.vue @@ -0,0 +1,322 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-circle-progress/u-circle-progress.vue b/src/uni_modules/vk-uview-ui/components/u-circle-progress/u-circle-progress.vue new file mode 100644 index 0000000..46e7c18 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-circle-progress/u-circle-progress.vue @@ -0,0 +1,220 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-col/u-col.vue b/src/uni_modules/vk-uview-ui/components/u-col/u-col.vue new file mode 100644 index 0000000..3b6cc64 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-col/u-col.vue @@ -0,0 +1,156 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-collapse-item/u-collapse-item.vue b/src/uni_modules/vk-uview-ui/components/u-collapse-item/u-collapse-item.vue new file mode 100644 index 0000000..bdce879 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-collapse-item/u-collapse-item.vue @@ -0,0 +1,205 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-collapse/u-collapse.vue b/src/uni_modules/vk-uview-ui/components/u-collapse/u-collapse.vue new file mode 100644 index 0000000..f6e4bf0 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-collapse/u-collapse.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-column-notice/u-column-notice.vue b/src/uni_modules/vk-uview-ui/components/u-column-notice/u-column-notice.vue new file mode 100644 index 0000000..709ca5c --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-column-notice/u-column-notice.vue @@ -0,0 +1,238 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-count-down/u-count-down.vue b/src/uni_modules/vk-uview-ui/components/u-count-down/u-count-down.vue new file mode 100644 index 0000000..0d7cc21 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-count-down/u-count-down.vue @@ -0,0 +1,175 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-count-down/utils.js b/src/uni_modules/vk-uview-ui/components/u-count-down/utils.js new file mode 100644 index 0000000..8c75005 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-count-down/utils.js @@ -0,0 +1,62 @@ +// 补0,如1 -> 01 +function padZero(num, targetLength = 2) { + let str = `${num}` + while (str.length < targetLength) { + str = `0${str}` + } + return str +} +const SECOND = 1000 +const MINUTE = 60 * SECOND +const HOUR = 60 * MINUTE +const DAY = 24 * HOUR +export function parseTimeData(time) { + const days = Math.floor(time / DAY) + const hours = Math.floor((time % DAY) / HOUR) + const minutes = Math.floor((time % HOUR) / MINUTE) + const seconds = Math.floor((time % MINUTE) / SECOND) + const milliseconds = Math.floor(time % SECOND) + return { + days, + hours, + minutes, + seconds, + milliseconds + } +} +export function parseFormat(format, timeData) { + let { + days, + hours, + minutes, + seconds, + milliseconds + } = timeData + // 如果格式化字符串中不存在DD(天),则将天的时间转为小时中去 + if (format.indexOf('DD') === -1) { + hours += days * 24 + } else { + // 对天补0 + format = format.replace('DD', padZero(days)) + } + // 其他同理于DD的格式化处理方式 + if (format.indexOf('HH') === -1) { + minutes += hours * 60 + } else { + format = format.replace('HH', padZero(hours)) + } + if (format.indexOf('mm') === -1) { + seconds += minutes * 60 + } else { + format = format.replace('mm', padZero(minutes)) + } + if (format.indexOf('ss') === -1) { + milliseconds += seconds * 1000 + } else { + format = format.replace('ss', padZero(seconds)) + } + return format.replace('SSS', padZero(milliseconds, 3)) +} +export function isSameSecond(time1, time2) { + return Math.floor(time1 / 1000) === Math.floor(time2 / 1000) +} diff --git a/src/uni_modules/vk-uview-ui/components/u-count-to/u-count-to.vue b/src/uni_modules/vk-uview-ui/components/u-count-to/u-count-to.vue new file mode 100644 index 0000000..2cad97c --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-count-to/u-count-to.vue @@ -0,0 +1,266 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-divider/u-divider.vue b/src/uni_modules/vk-uview-ui/components/u-divider/u-divider.vue new file mode 100644 index 0000000..6f8d7e6 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-divider/u-divider.vue @@ -0,0 +1,153 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-dropdown-item/u-dropdown-item.vue b/src/uni_modules/vk-uview-ui/components/u-dropdown-item/u-dropdown-item.vue new file mode 100644 index 0000000..380268a --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-dropdown-item/u-dropdown-item.vue @@ -0,0 +1,166 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-dropdown/u-dropdown.vue b/src/uni_modules/vk-uview-ui/components/u-dropdown/u-dropdown.vue new file mode 100644 index 0000000..b9438b4 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-dropdown/u-dropdown.vue @@ -0,0 +1,299 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-empty/u-empty.vue b/src/uni_modules/vk-uview-ui/components/u-empty/u-empty.vue new file mode 100644 index 0000000..2c77b24 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-empty/u-empty.vue @@ -0,0 +1,193 @@ + + + + + diff --git a/src/uni_modules/vk-uview-ui/components/u-field/u-field.vue b/src/uni_modules/vk-uview-ui/components/u-field/u-field.vue new file mode 100644 index 0000000..efa31e6 --- /dev/null +++ b/src/uni_modules/vk-uview-ui/components/u-field/u-field.vue @@ -0,0 +1,402 @@ +