feat(custom): 新增消息订阅
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-08-27 17:06:59 +08:00
parent f199320de0
commit 1d8532eccf
104 changed files with 2350 additions and 2477 deletions

View File

@@ -15,8 +15,8 @@
<script setup lang="ts">
// import { computed, ref } from "vue";
import Taro from "@tarojs/taro";
import { login } from "@/api/user";
import Taro from '@tarojs/taro';
import {login} from '@/api/user';
defineProps({
visible: {
@@ -25,38 +25,38 @@ defineProps({
},
});
const emit = defineEmits(["update:visible", "ok"]);
const emit = defineEmits(['update:visible', 'ok']);
const onCancel = () => {
emit("update:visible", false);
emit('update:visible', false);
};
const onOk = () => {
Taro.showLoading({
title: "正在授权中",
title: '正在授权中',
mask: true,
});
Taro.getUserProfile({
desc: "完善用户资料",
success: async (user) => {
desc: '完善用户资料',
success: async user => {
Taro.login({
success: async ({ code }) => {
success: async ({code}) => {
try {
const { data }: any = await login({
const {data}: any = await login({
code: code,
nickName: user.userInfo.nickName,
avatarUrl: user.userInfo.avatarUrl,
});
Taro.setStorageSync("token", data.token);
emit("ok", false);
Taro.setStorageSync('token', data.token);
emit('ok', false);
} catch (error) {
Taro.showToast({
title: error.message,
icon: "none",
icon: 'none',
});
}
},
fail: (err) => {
fail: err => {
console.log(err);
},
complete: () => {
@@ -64,7 +64,7 @@ const onOk = () => {
},
});
},
fail: (err) => {
fail: err => {
console.log(err);
},
complete: () => {

View File

@@ -1,18 +1,18 @@
<template>
<view class="head-wrapper" :style="{ top: BarHeight + 'px' }">
<view class="head-wrapper" :style="{top: BarHeight + 'px'}">
<view class="head-menu">
<Left class="iconfont" @click="returns" />
<view class="line"></view>
<Home class="iconfont" @click="goHome" />
</view>
<text style="width: 2000px;text-align: center;">{{ props.title }}</text>
<text style="width: 2000px; text-align: center">{{ props.title }}</text>
</view>
</template>
<script setup lang="ts">
import Taro from "@tarojs/taro";
import { computed } from "vue";
import { Home, Left } from "@nutui/icons-vue-taro";
import Taro from '@tarojs/taro';
import {computed} from 'vue';
import {Home, Left} from '@nutui/icons-vue-taro';
const statusBarHeight = Taro.getSystemInfoSync()?.statusBarHeight as number;
const BarHeight = computed(() => statusBarHeight - 7);
@@ -20,7 +20,7 @@ const BarHeight = computed(() => statusBarHeight - 7);
const props = defineProps({
title: {
type: String,
default: "",
default: '',
},
});
@@ -32,7 +32,7 @@ const returns = () => {
const goHome = () => {
Taro.switchTab({
url: "/pages/index/index",
url: '/pages/index/index',
});
};
</script>

View File

@@ -185,8 +185,14 @@ const toPage = async (url: string) => {
};
const toMerDetails = item => {
Taro.navigateTo({
url: `/pages/mer/mer_detail/index?bid=${item.bid}`,
Taro.requestSubscribeMessage({
tmplIds: ['ewjjRxDJAQ_RbKU8CIjMNwfJXazyGQ95XbpKW16vMZs'],
entityIds: [],
complete: () => {
Taro.navigateTo({
url: `/pages/mer/mer_detail/index?bid=${item.bid}`,
});
},
});
};

View File

@@ -1,6 +1,6 @@
<script setup lang="ts">
import { ref } from "vue";
import Taro from "@tarojs/taro";
import {ref} from 'vue';
import Taro from '@tarojs/taro';
const show = ref(false);
@@ -14,7 +14,7 @@ defineProps({
src: {
required: true,
type: String,
default: "",
default: '',
},
type: Number,
cb: {
@@ -25,7 +25,7 @@ defineProps({
});
Taro.useLoad(async () => {
if (Taro.getStorageSync("token")) show.value = true;
if (Taro.getStorageSync('token')) show.value = true;
// const res = await getSignRecord()
// console.log(res)
});
@@ -35,8 +35,7 @@ Taro.useLoad(async () => {
<nut-overlay
v-model:visible="show"
:lock-scroll="true"
:close-on-click-overlay="false"
>
:close-on-click-overlay="false">
<view class="wrapper">
<view @click.stop="cb(type)">
<image class="image" :src="src" />

View File

@@ -5,80 +5,68 @@
<view
class="toolbar"
@click="format"
style="max-height: 240px; overflow-y: auto"
>
style="max-height: 240px; overflow-y: auto">
<!-- 加粗 -->
<view
:class="data.formats.bold ? 'ql-active' : ''"
class="iconfont icon-zitijiacu"
data-name="bold"
></view>
data-name="bold"></view>
<!-- 斜体 -->
<view
:class="data.formats.italic ? 'ql-active' : ''"
class="iconfont icon-zitixieti"
data-name="italic"
></view>
data-name="italic"></view>
<!-- 下划线 -->
<view
:class="data.formats.underline ? 'ql-active' : ''"
class="iconfont icon-zitixiahuaxian"
data-name="underline"
></view>
data-name="underline"></view>
<!-- 对齐方式 -->
<view
:class="data.formats.align === 'left' ? 'ql-active' : ''"
class="iconfont icon-zuoduiqi"
data-name="align"
data-value="left"
></view>
data-value="left"></view>
<!-- 对齐方式居中 -->
<view
:class="data.formats.align === 'center' ? 'ql-active' : ''"
class="iconfont icon-juzhongduiqi"
data-name="align"
data-value="center"
></view>
data-value="center"></view>
<!-- 对齐方式 -->
<view
:class="data.formats.align === 'right' ? 'ql-active' : ''"
class="iconfont icon-youduiqi"
data-name="align"
data-value="right"
></view>
data-value="right"></view>
<!-- 对齐方式两侧 -->
<view
:class="data.formats.align === 'justify' ? 'ql-active' : ''"
class="iconfont icon-zuoyouduiqi"
data-name="align"
data-value="justify"
></view>
data-value="justify"></view>
<!-- 有序排列 -->
<view
:class="data.formats.list === 'ordered' ? 'ql-active' : ''"
class="iconfont icon-youxupailie"
data-name="list"
data-value="ordered"
></view>
data-value="ordered"></view>
<!-- 无序排列 -->
<view
:class="data.formats.list === 'bullet' ? 'ql-active' : ''"
class="iconfont icon-wuxupailie"
data-name="list"
data-value="bullet"
></view>
data-value="bullet"></view>
<!-- 取消缩进 -->
<view
class="iconfont icon-outdent"
data-name="indent"
data-value="-1"
></view>
data-value="-1"></view>
<!-- 缩进 -->
<view
class="iconfont icon-indent"
data-name="indent"
data-value="+1"
></view>
data-value="+1"></view>
<!-- 添加分割线 -->
<view class="iconfont icon-fengexian" @click="insertDivider"></view>
<!-- 插入图片 -->
@@ -88,22 +76,19 @@
:class="data.formats.header === 3 ? 'ql-active' : ''"
class="iconfont icon-H"
data-name="header"
:data-value="3"
></view>
:data-value="3"></view>
<!-- 下标 -->
<view
:class="data.formats.script === 'sub' ? 'ql-active' : ''"
class="iconfont icon-zitixiabiao"
data-name="script"
data-value="sub"
></view>
data-value="sub"></view>
<!-- 上标 -->
<view
:class="data.formats.script === 'super' ? 'ql-active' : ''"
class="iconfont icon-zitishangbiao"
data-name="script"
data-value="super"
></view>
data-value="super"></view>
<view class="iconfont icon-undo" @click="undo"></view>
<view class="iconfont icon-redo" @click="redo"></view>
</view>
@@ -115,8 +100,7 @@
@statuschange="onStatusChange"
:show-img-resize="true"
@ready="onEditorReady"
@input="getCtx"
/>
@input="getCtx" />
</view>
</view>
</view>
@@ -124,29 +108,29 @@
</template>
<script lang="ts" setup>
import { reactive } from "vue";
import Taro from "@tarojs/taro";
import { BASE_URL } from "@/utils/request";
import {reactive} from 'vue';
import Taro from '@tarojs/taro';
import {BASE_URL} from '@/utils/request';
const { content } = defineProps<{
const {content} = defineProps<{
content: string;
}>();
let emits = defineEmits(["input"]);
let emits = defineEmits(['input']);
const data = reactive<any>({
editorCtx: "",
editorCtx: '',
readOnly: false,
placeholder: "请输入商品详情...",
richText: "",
placeholder: '请输入商品详情...',
richText: '',
formats: {},
});
function onEditorReady() {
// 富文本节点渲染完成
Taro.createSelectorQuery()
.select("#editor")
.context((res) => {
.select('#editor')
.context(res => {
data.editorCtx = res.context;
// 初始化数据
if (content) {
@@ -159,9 +143,9 @@ function onEditorReady() {
}
// 失去焦点时,获取富文本的内容
function getCtx(e: { detail: { html: any } }) {
function getCtx(e: {detail: {html: any}}) {
data.richText = e.detail.html;
emits("input", e.detail.html);
emits('input', e.detail.html);
}
// 撤销操作
@@ -175,15 +159,15 @@ function redo() {
}
//修改样式
function format(e: { target: { dataset: { name: any; value: any } } }) {
function format(e: {target: {dataset: {name: any; value: any}}}) {
// console.log("format", e.target.dataset);
let { name, value } = e.target.dataset;
let {name, value} = e.target.dataset;
if (!name) return;
data.editorCtx.format(name, value);
}
//通过 Context 方法改变编辑器内样式时触发,返回选区已设置的样式
function onStatusChange(e: { detail: any }) {
function onStatusChange(e: {detail: any}) {
data.formats = e.detail;
}
@@ -196,16 +180,16 @@ function insertDivider() {
function insertImage() {
Taro.chooseImage({
count: 1,
sizeType: ["original", "compressed"],
sourceType: ["album", "camera"],
success: (res) => {
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: res => {
// 上传图片的逻辑各有不同,自行调整即可
Taro.uploadFile({
url: `${BASE_URL}/upload`,
name: "file",
header: { token: Taro.getStorageSync("token") },
name: 'file',
header: {token: Taro.getStorageSync('token')},
filePath: res.tempFilePaths[0],
success: (res) => {
success: res => {
console.log(res);
const imgData = JSON.parse(res.data) as {
code: number;
@@ -215,19 +199,19 @@ function insertImage() {
if (imgData.code === 200) {
// 将图片展示在编辑器中
data.editorCtx.insertImage({
width: "100%",
height: "auto",
width: '100%',
height: 'auto',
src: imgData.data.data,
alt: "图像",
alt: '图像',
success: function () {
console.log("insert image success");
console.log('insert image success');
},
});
} else {
console.log("上传失败");
console.log('上传失败');
}
},
fail: (err) => {
fail: err => {
console.log(err);
},
});
@@ -237,7 +221,7 @@ function insertImage() {
</script>
<style lang="scss">
@import "../static/font_4211210_2x20brbrv94.css";
@import '../static/font_4211210_2x20brbrv94.css';
.wrapper {
height: 100%;
@@ -266,7 +250,7 @@ function insertImage() {
.toolbar {
box-sizing: border-box;
border-bottom: 0;
font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
}
.ql-container {

View File

@@ -14,14 +14,13 @@
@touchstart="touchStart"
@touchmove="touchMove"
@touchend="touchEnd"
@error="error"
>
@error="error">
</canvas>
</template>
<script setup lang="ts" name="ucharts">
import uCharts from "../utils/js_sdk/u-charts.min.js";
import Taro from "@tarojs/taro";
import uCharts from '../utils/js_sdk/u-charts.min.js';
import Taro from '@tarojs/taro';
const canvases = {};
@@ -29,7 +28,7 @@ const props = defineProps({
chartType: {
required: true,
type: String,
default: "column",
default: 'column',
},
opts: {
required: true,
@@ -40,7 +39,7 @@ const props = defineProps({
},
canvasId: {
type: String,
default: "u-canvas",
default: 'u-canvas',
},
cWidth: {
default: 350,
@@ -60,10 +59,10 @@ Taro.useLoad(() => {
const init = () => {
switch (props.chartType) {
case "column":
case 'column':
initColumnChart();
break;
case "line":
case 'line':
initLineChart();
break;
default:
@@ -75,9 +74,9 @@ const initColumnChart = () => {
const ctx = Taro.createCanvasContext(props.canvasId);
canvases[props.canvasId] = new uCharts({
context: ctx,
type: "column",
type: 'column',
fontSize: 11,
background: "#FFFFFF",
background: '#FFFFFF',
pixelRatio: props.pixelRatio,
animation: true,
categories: props.opts.categories,
@@ -99,9 +98,9 @@ const initColumnChart = () => {
},
extra: {
column: {
type: "group",
type: 'group',
width: 30,
activeBgColor: "#000000",
activeBgColor: '#000000',
activeBgOpacity: 0.08,
},
},
@@ -112,12 +111,12 @@ const initLineChart = () => {
const ctx = Taro.createCanvasContext(props.canvasId);
canvases[props.canvasId] = new uCharts({
context: ctx,
type: "line",
type: 'line',
fontSize: 11,
legend: true,
dataLabel: false,
dataPointShape: true,
background: "#FFFFFF",
background: '#FFFFFF',
pixelRatio: props.pixelRatio,
categories: props.opts.categories,
series: props.opts.series,
@@ -133,21 +132,21 @@ const initLineChart = () => {
disableGrid: true,
},
yAxis: {
gridType: "dash",
gridColor: "#CCCCCC",
gridType: 'dash',
gridColor: '#CCCCCC',
dashLength: 8,
splitNumber: 5,
min: 10,
max: 180,
format: (val) => {
return val.toFixed(0) + "元";
format: val => {
return val.toFixed(0) + '元';
},
},
width: props.cWidth * props.pixelRatio,
height: props.cHeight * props.pixelRatio,
extra: {
line: {
type: "straight",
type: 'straight',
},
},
});
@@ -156,7 +155,7 @@ const initLineChart = () => {
const touchStart = (e: any) => {
canvases[props.canvasId].showToolTip(e, {
format: function (item: any, category: any) {
return category + " " + item.name + ":" + item.data;
return category + ' ' + item.name + ':' + item.data;
},
});
canvases[props.canvasId].scrollStart(e);

View File

@@ -6,15 +6,14 @@
:headers="config.headers"
@success="success"
@failure="failure"
:multiple="multiple"
>
:multiple="multiple">
</nut-uploader>
</template>
<script setup lang="ts">
import { BASE_URL } from "@/utils/request";
import { computed, ref } from "vue";
import Taro from "@tarojs/taro";
import {BASE_URL} from '@/utils/request';
import {computed, ref} from 'vue';
import Taro from '@tarojs/taro';
const props = defineProps({
list: {
@@ -31,17 +30,17 @@ const props = defineProps({
},
});
const emits = defineEmits(["update:list"]);
const emits = defineEmits(['update:list']);
const fileList = computed({
get: () => props.list,
set: (val) => emits("update:list", val),
set: val => emits('update:list', val),
});
const config = ref({
url: `${BASE_URL}/upload`,
headers: {
token: Taro.getStorageSync("token"),
token: Taro.getStorageSync('token'),
},
});
@@ -49,15 +48,15 @@ const success = (res: any) => {
const data = JSON.parse(res.responseText.data);
res.fileItem.url = data.data.data;
Taro.showToast({
title: "上传成功",
icon: "success",
title: '上传成功',
icon: 'success',
});
};
const failure = () => {
Taro.showToast({
title: "上传失败",
icon: "error",
title: '上传失败',
icon: 'error',
});
};
</script>

View File

@@ -1,10 +1,10 @@
<script lang="ts" setup>
import { computed, ref } from "vue";
import Taro from "@tarojs/taro";
import headImg from "../static/def_avatar.png";
import logoImg from "../static/logo.jpg";
import { BASE_URL } from "@/utils/request";
import { getPhone, login } from "@/api/user";
import {computed, ref} from 'vue';
import Taro from '@tarojs/taro';
import headImg from '../static/def_avatar.png';
import logoImg from '../static/logo.jpg';
import {BASE_URL} from '@/utils/request';
import {getPhone, login} from '@/api/user';
const props = defineProps({
isShow: {
@@ -12,18 +12,18 @@ const props = defineProps({
default: false,
},
});
const emits = defineEmits(["closeEdit", "update:isShow"]);
const emits = defineEmits(['closeEdit', 'update:isShow']);
const userInfo = ref({
nickname: "",
avatar: "",
phone: "",
nickname: '',
avatar: '',
phone: '',
});
const show = computed({
get: (): boolean => props.isShow,
set: (val) => {
emits("update:isShow", val);
set: val => {
emits('update:isShow', val);
},
});
@@ -32,15 +32,15 @@ const mp_is_new = ref(true);
const canvasStatus = ref(false);
const closeAttr = () => {
emits("closeEdit");
emits('closeEdit');
};
const onChooseAvatar = (e) => {
const { avatarUrl } = e.detail;
const onChooseAvatar = e => {
const {avatarUrl} = e.detail;
Taro.uploadFile({
url: `${BASE_URL}/upload`,
filePath: avatarUrl,
name: "file",
name: 'file',
success: function (res) {
const data = JSON.parse(res.data);
userInfo.value.avatar = data.data.data;
@@ -54,10 +54,10 @@ const uploadPic = () => {
const getPhoneNumber = async (e: any) => {
Taro.showLoading({
title: "授权手机号中",
title: '授权手机号中',
mask: true,
});
const { code } = e.detail;
const {code} = e.detail;
const res = await getPhone({
code: code,
});
@@ -68,39 +68,39 @@ const getPhoneNumber = async (e: any) => {
const formSubmit = async (e: any) => {
if (!userInfo.value.avatar)
return Taro.showToast({
title: "请上传头像",
icon: "none",
title: '请上传头像',
icon: 'none',
});
userInfo.value.nickname = e.detail.value.nickname;
if (!userInfo.value.nickname)
return Taro.showToast({
title: "请输入昵称",
icon: "none",
title: '请输入昵称',
icon: 'none',
});
if (!userInfo.value.phone)
return Taro.showToast({
title: "请授权手机号码",
icon: "none",
title: '请授权手机号码',
icon: 'none',
});
const res = await login({
Code: Taro.getStorageSync("wx_code"),
Code: Taro.getStorageSync('wx_code'),
NickName: userInfo.value.nickname,
AvatarUrl: userInfo.value.avatar,
Phone: userInfo.value.phone,
Referee: Taro.getStorageSync("bind_id") || "",
Referee: Taro.getStorageSync('bind_id') || '',
});
emits("closeEdit");
emits('closeEdit');
Taro.showToast({
title: res.msg,
icon: "success",
icon: 'success',
duration: 2000,
});
Taro.setStorageSync("token", res.data.token);
Taro.setStorageSync('token', res.data.token);
setTimeout(() => {
Taro.removeStorageSync("wx_code");
Taro.removeStorageSync("bind_id");
Taro.removeStorageSync('wx_code');
Taro.removeStorageSync('bind_id');
Taro.switchTab({
url: "/pages/user/index",
url: '/pages/user/index',
});
}, 2000);
};
@@ -112,11 +112,10 @@ const formSubmit = async (e: any) => {
position="bottom"
safe-area-inset-bottom
closeable
:style="{ padding: '20px 10px' }"
:style="{padding: '20px 10px'}"
v-model:visible="show"
@close="closeAttr"
:close-on-click-overlay="false"
>
:close-on-click-overlay="false">
<view class="mp-data">
<image class="image" :src="logoImg"></image>
<text class="mp-name">捷兑通 申请</text>
@@ -133,23 +132,19 @@ const formSubmit = async (e: any) => {
<view
class="avatar-box"
v-if="!mp_is_new"
@click.stop="uploadPic"
>
@click.stop="uploadPic">
<image
:src="userInfo.avatar || headImg"
mode="aspectFill"
></image>
mode="aspectFill"></image>
</view>
<button
v-else
class="avatar-box"
open-type="chooseAvatar"
@chooseavatar="onChooseAvatar"
>
@chooseavatar="onChooseAvatar">
<image
:src="userInfo.avatar || headImg"
mode="aspectFill"
></image>
mode="aspectFill"></image>
</button>
</view>
</view>
@@ -163,8 +158,7 @@ const formSubmit = async (e: any) => {
placeholder="请输入昵称"
name="nickname"
:maxlength="16"
:value="userInfo.nickname"
/>
:value="userInfo.nickname" />
</view>
</view>
</view>
@@ -174,9 +168,8 @@ const formSubmit = async (e: any) => {
<view class="input">
<button
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
{{ !userInfo.phone ? "请授权手机号" : "授权成功" }}
@getphonenumber="getPhoneNumber">
{{ !userInfo.phone ? '请授权手机号' : '授权成功' }}
</button>
</view>
</view>