diff --git a/src/app.config.ts b/src/app.config.ts
index a9bb506..bfc9c17 100644
--- a/src/app.config.ts
+++ b/src/app.config.ts
@@ -9,7 +9,8 @@ export default defineAppConfig({
'pages/login/index',
'pages/web-view/index',
'pages/contact-pass-records/index',
- 'pages/contact-edit-logs/index'
+ 'pages/contact-edit-logs/index',
+ 'pages/contact-send-invite-sms/index'
],
window: {
backgroundTextStyle: 'light',
diff --git a/src/components/contact-form/index.vue b/src/components/contact-form/index.vue
index 257771c..25fed48 100644
--- a/src/components/contact-form/index.vue
+++ b/src/components/contact-form/index.vue
@@ -8,13 +8,27 @@ import { reactive, ref } from 'vue';
import {BjxHelper} from "../../utils";
import {useContactsStore} from "../../stores/contacts";
import {useContactItemStore} from "../../stores/contact-item";
-
-const props = defineProps(['data'])
+import {useContactVisitRecordStore} from "../../stores/contact-visit-record";
const contacts = useContactsStore()
const contact = useContactItemStore()
+const contactVisitRecord = useContactVisitRecordStore()
contact.setNewAvatar("")
+if (contact.contact.id) {
+ contactVisitRecord.getVisitRecord(contact.contact.id)
+ .then(contactVisitRecord => {
+ console.log("contactVisitRecord", contactVisitRecord)
+ if (contactVisitRecord) {
+ contact.contact.nextVisitDate = contactVisitRecord.visitDate
+ console.log(contactVisitRecord.visitDate)
+ console.log(contact.contact)
+ }
+ })
+ .catch(e => console.log(e))
+}
+console.log("id", contact.contact.id)
+
const onShowSuggestionsMenu = ref(false)
const state = reactive({
@@ -28,7 +42,7 @@ const openSwitch = (param) => {
};
const closeSwitch = (param) => {
state[`${param}`] = false;
-};
+}
const setChooseDate = (param) => {
contact.contact.nextVisitDate = param[3]
}
@@ -99,7 +113,7 @@ const onNickNameSelected = (value) => {
-
+
diff --git a/src/pages/contact-edit/index.vue b/src/pages/contact-edit/index.vue
index 7882149..327b842 100644
--- a/src/pages/contact-edit/index.vue
+++ b/src/pages/contact-edit/index.vue
@@ -1,15 +1,18 @@
-
@@ -125,7 +157,7 @@ const onDeleteConfirm = (item) => {
更新来访联系人信息,并设置下次到访时间
- 保存
+ 保存
@@ -142,12 +174,16 @@ const onDeleteConfirm = (item) => {
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ 保存并发送邀约短信
+
取消阻止此联系人
diff --git a/src/pages/contact-new/index.vue b/src/pages/contact-new/index.vue
index 7d9d0b1..62e6787 100644
--- a/src/pages/contact-new/index.vue
+++ b/src/pages/contact-new/index.vue
@@ -1,9 +1,10 @@
-
@@ -53,15 +80,20 @@ const onSaveClicked = () => {
新建来访联系人,并设置到访时间
- 保存
+ 保存
-
+
+
+ 保存并发送邀约短信
+
+
+
diff --git a/src/pages/contact-send-invite-sms/index.config.ts b/src/pages/contact-send-invite-sms/index.config.ts
new file mode 100644
index 0000000..5662c12
--- /dev/null
+++ b/src/pages/contact-send-invite-sms/index.config.ts
@@ -0,0 +1,6 @@
+export default definePageConfig({
+ navigationBarTitleText: '',
+ usingComponents: {},
+ navigationStyle: 'custom',
+ disableScroll: true
+})
diff --git a/src/pages/contact-send-invite-sms/index.scss b/src/pages/contact-send-invite-sms/index.scss
new file mode 100644
index 0000000..b41e6ef
--- /dev/null
+++ b/src/pages/contact-send-invite-sms/index.scss
@@ -0,0 +1,20 @@
+page {
+ height: 100%;
+}
+
+.nut-navbar {
+ background: transparent;
+}
+
+.scroll {
+ flex: 1;
+ overflow: scroll;
+}
+
+.save-button {
+ font-size: 36px
+}
+
+.nut-action-sheet__item {
+ color: red !important;
+}
diff --git a/src/pages/contact-send-invite-sms/index.vue b/src/pages/contact-send-invite-sms/index.vue
new file mode 100644
index 0000000..5e7a2df
--- /dev/null
+++ b/src/pages/contact-send-invite-sms/index.vue
@@ -0,0 +1,143 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 发送短信
+
+ 此联系人的最近编辑记录
+
+
+
+
+
+
+
+
+
+ 刷新
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/stores/contact-item.ts b/src/stores/contact-item.ts
index f28a1de..0918754 100644
--- a/src/stores/contact-item.ts
+++ b/src/stores/contact-item.ts
@@ -15,6 +15,9 @@ export const useContactItemStore = defineStore('contact-item', () => {
contact.value = contactItem
console.log("setContact", contact.value)
}
+ function setContactNextVisitDate(nextVisitDate: string) {
+ contact.value.nextVisitDate = nextVisitDate
+ }
function setNewAvatar(avatar: string) {
contactNewAvatar.value = avatar
}
@@ -30,8 +33,8 @@ export const useContactItemStore = defineStore('contact-item', () => {
avatar: "",
phone: "",
company: "",
- nextVisitDate: undefined,
- firstCharPinyin: ""
+ nextVisitDate: "",
+ firstCharPinyin: "",
}
}
@@ -45,7 +48,9 @@ export const useContactItemStore = defineStore('contact-item', () => {
isVip: $isVIP,
flexVisit: $flexVisit,
resourceId: $resourceId
- } )
+ } ) {
+ id
+ }
}
`
@@ -60,7 +65,9 @@ export const useContactItemStore = defineStore('contact-item', () => {
isVip: $isVIP,
flexVisit: $flexVisit,
resourceId: $resourceId
- } )
+ } ) {
+ id
+ }
}
`
@@ -95,7 +102,10 @@ export const useContactItemStore = defineStore('contact-item', () => {
console.log(r)
const resourceId = r.data.resourceId
GQLRequest.query(CREATE_VISITOR, { staffId, name, nickName, phone, company, isVIP, flexVisit, resourceId })
- .then(r=> resolve(r))
+ .then(r=> {
+ contact.value.id = r.data.createVisitor.id
+ resolve(r)
+ })
.catch(e=> reject(e))
}).catch(e => {
reject(e.msg)
@@ -103,7 +113,10 @@ export const useContactItemStore = defineStore('contact-item', () => {
}
else {
GQLRequest.query(CREATE_VISITOR, { staffId, name, nickName, phone, company, isVIP, flexVisit })
- .then(r=> resolve(r))
+ .then(r=> {
+ contact.value.id = r.data.createVisitor.id
+ resolve(r)
+ })
.catch(e=> reject(e))
}
})
@@ -127,7 +140,10 @@ export const useContactItemStore = defineStore('contact-item', () => {
console.log(r)
const resourceId = r.data.resourceId
GQLRequest.query(UPDATE_VISITOR, {staffId, id, name, nickName, phone, company, isVIP, flexVisit, resourceId })
- .then(r=> resolve(r))
+ .then(r=> {
+ // contact.value.id = r.data.updateVisitor.id
+ resolve(r)
+ })
.catch(e=> reject(e))
}).catch(e => {
reject(e.msg)
@@ -135,7 +151,10 @@ export const useContactItemStore = defineStore('contact-item', () => {
}
else {
GQLRequest.query(UPDATE_VISITOR, {staffId, id, name, nickName, phone, company, isVIP, flexVisit })
- .then(r=> resolve(r))
+ .then(r=> {
+ // contact.value.id = r.data.updateVisitor.id
+ resolve(r)
+ })
.catch(e=> reject(e))
}
})
@@ -178,5 +197,5 @@ export const useContactItemStore = defineStore('contact-item', () => {
}
- return { contact, setContact, createVisitor, updateVisitor, deleteVisitor, getEmptyContactData, setNewAvatar, setBlockStatus }
+ return { contact, setContact, createVisitor, updateVisitor, deleteVisitor, getEmptyContactData, setNewAvatar, setBlockStatus, setContactNextVisitDate }
})
diff --git a/src/stores/contact-visit-record.ts b/src/stores/contact-visit-record.ts
new file mode 100644
index 0000000..ae5a860
--- /dev/null
+++ b/src/stores/contact-visit-record.ts
@@ -0,0 +1,164 @@
+// https://pinia.esm.dev/introduction.html
+import { defineStore } from 'pinia'
+import {GQLRequest, PinyinHelper, Session} from "../utils";
+import {gql} from "graphql-tag";
+import {ContactData} from "./contacts";
+import {ref, Ref, UnwrapRef} from "vue";
+import Taro from "@tarojs/taro";
+import dayjs from "dayjs";
+
+export interface ContactVisitRecord {
+ id: number
+ visitorId: number
+ userId: number
+ receiverName?: string
+ receiverPhone?: string
+ recordStatus?: number
+ visitDate: string
+ visitCode?: string
+}
+
+export const useContactVisitRecordStore = defineStore('contact-visit-record', () => {
+
+ const visitRecord: Ref> = ref(null)
+
+ function reset() {
+ visitRecord.value = null
+ }
+ function setContact(contactItem: ContactData) {
+ contact.value = contactItem
+ console.log("setContact", contact.value)
+ }
+ function setNewAvatar(avatar: string) {
+ contactNewAvatar.value = avatar
+ }
+
+ const GET_VISIT_RECORD = gql`
+ query ($visitorId: ID, $limit: Int ) {
+ visitRecords(visitorId: $visitorId, limit: $limit) {
+ id
+ visitorId
+ userId
+ visitDate
+ visitorCode
+ }
+ }
+ `
+
+ const CREATE_VISIT_RECORD = gql`
+ mutation CreateVisitRecord($staffId: ID!, $visitorId: ID!, $visitDate: Date!) {
+ createVisitRecord( staffId: $staffId, input: {
+ visitorId: $visitorId,
+ visitDate: $visitDate,
+ } ) {
+ id
+ visitorId
+ userId
+ visitDate
+ visitorCode
+ }
+ }
+ `
+
+ const UPDATE_VISIT_RECORD = gql`
+ mutation UpdateVisitRecord($staffId: ID!, $visitRecordId: ID!, $visitorId: ID!, $visitDate: Date!) {
+ updateVisitRecord( staffId: $staffId, input: {
+ id: $visitRecordId,
+ visitorId: $visitorId,
+ visitDate: $visitDate,
+ } ) {
+ id
+ visitorId
+ userId
+ visitDate
+ visitorCode
+ }
+ }
+ `
+
+ function getVisitRecord(visitorId: string) {
+ reset()
+ const limit = 1
+ return new Promise((resolve, reject) => {
+ GQLRequest.query(GET_VISIT_RECORD, { visitorId, limit })
+ .then(result=> {
+ if (result.code == 500) {
+ reject("Network Error")
+ } else {
+ console.log("result", result)
+ if (result.data.visitRecords.length > 0) {
+ const item = result.data.visitRecords[0]
+ createData(item)
+ }
+ resolve(visitRecord.value)
+ }
+ })
+ .catch(e => {
+ reject()
+ })
+ })
+ }
+
+ function createData(item: any) {
+ const todayString = dayjs().format("YYYY-MM-DD")
+ const dateDiff = dayjs(todayString + " 00:00:00").diff(dayjs(item.visitDate, "YYYY-MM-DD"))
+ if (dateDiff <= 0) {
+ visitRecord.value = {
+ id: item.id,
+ visitorId: item.visitorId,
+ userId: item.userId,
+ receiverName: undefined,
+ receiverPhone: undefined,
+ recordStatus: undefined,
+ visitDate: item.visitDate,
+ visitCode: undefined,
+ } as ContactVisitRecord
+ }
+ }
+
+ function save(visitorId: string, date: string) {
+ return new Promise((resolve, reject) => {
+ if (visitRecord.value) {
+
+ updateVisitRecord(visitRecord.value.id, visitorId, date).then(r => resolve(r))
+ .catch(e => reject(e))
+ }
+ else {
+ createVisitRecord(visitorId, date).then(r => resolve(r))
+ .catch(e => reject(e))
+ }
+ })
+ }
+
+ function createVisitRecord(visitorId: string, visitDate: string) {
+ const staffId = Session.get("staff").id
+ return new Promise((resolve, reject) => {
+ GQLRequest.query(CREATE_VISIT_RECORD, { staffId, visitorId, visitDate })
+ .then(r=> {
+ if (r.code == 500) reject("Network Error")
+ else {
+ console.log(r)
+ createData(r.data.createVisitRecord)
+ resolve(r)
+ }
+ })
+ .catch(e=> reject(e))
+ })
+
+ }
+
+ function updateVisitRecord(visitRecordId: string, visitorId: string, visitDate: string) {
+ const staffId = Session.get("staff").id
+ return new Promise((resolve, reject) => {
+ GQLRequest.query(UPDATE_VISIT_RECORD, { staffId, visitRecordId, visitorId, visitDate })
+ .then(r=> {
+ if (r.code == 500) reject("Network Error")
+ else resolve(r)
+ })
+ .catch(e=> reject(e))
+ })
+
+ }
+
+ return { getVisitRecord , save }
+})
diff --git a/src/stores/contacts.ts b/src/stores/contacts.ts
index d215f56..bab2f67 100644
--- a/src/stores/contacts.ts
+++ b/src/stores/contacts.ts
@@ -16,7 +16,7 @@ export interface ContactData {
avatar: string
phone: string
company: string
- nextVisitDate?: string
+ nextVisitDate: string
firstCharPinyin: string
}
@@ -63,7 +63,8 @@ export const useContactsStore = defineStore('contacts', () => {
flexVisit: item.flexVisit,
isBlock: item.isBlock,
isVIP: item.isVip,
- firstCharPinyin: PinyinHelper.getPinyinGroupName(item.name)
+ firstCharPinyin: PinyinHelper.getPinyinGroupName(item.name),
+ nextVisitDate: ""
} as ContactData)
}
allContacts.value = items.sort((a, b) => a.firstCharPinyin.localeCompare(b.firstCharPinyin));