微信小程序,访客邀约
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

236 regels
6.9 KiB

  1. <script setup lang="ts">
  2. import { reactive } from 'vue'
  3. import { View } from '@tarojs/components'
  4. import './index.scss'
  5. import {Route, Session, weappAuth} from "../../utils";
  6. import {
  7. GroupedContactPassRecords,
  8. useContactPassRecordsStore
  9. } from "../../stores/contact-pass-records";
  10. import {Router} from "tarojs-router-next";
  11. import { BjxHelper } from "../../utils";
  12. import {ContactEditLog, useContactEditLogsStore} from "../../stores/contact-edit-logs";
  13. import {useContactItemStore} from "../../stores/contact-item";
  14. import {useContactVisitRecordStore} from "../../stores/contact-visit-record";
  15. import Taro from "@tarojs/taro";
  16. const contactData = Router.getData()
  17. console.log("contactData", contactData)
  18. const contact = useContactItemStore()
  19. const contactVisitRecord = useContactVisitRecordStore()
  20. const state = reactive({
  21. isDateSelectorVisible: false,
  22. isSmsSent: false
  23. });
  24. const goBack = () => {
  25. Router.back(undefined, { delta: 2 })
  26. }
  27. const openSwitch = (param) => {
  28. state[`${param}`] = true;
  29. };
  30. const closeSwitch = (param) => {
  31. state[`${param}`] = false;
  32. }
  33. const setChooseDate = (param) => {
  34. Taro.showLoading({
  35. title: 'loading',
  36. })
  37. contact.contact.nextVisitDate = param[3]
  38. if (contact.contact.nextVisitDate !== "") {
  39. contactVisitRecord.save(contact.contact.id, contact.contact.nextVisitDate).then( visitRecordResult => {
  40. console.log("save contactVisitRecord DONE")
  41. Taro.hideLoading()
  42. })
  43. }
  44. else {
  45. Taro.hideLoading()
  46. }
  47. }
  48. const onSmsSend = () => {
  49. console.log(contactVisitRecord.visitRecord)
  50. if (contactVisitRecord.visitRecord == null){
  51. Taro.showToast({
  52. title: '请选择邀请到访的日期',
  53. icon: 'none',
  54. duration: 2000})
  55. }
  56. else {
  57. Taro.request({
  58. method: 'GET',
  59. url: SERVER_URL + '/system/visitor/sms/send-sms',
  60. header: {
  61. Authorization: 'Bearer ' + Session.get('access_token'),
  62. },
  63. data: {
  64. visitRecordId: contactVisitRecord.visitRecord.id,
  65. staffId: Session.get("staff").id
  66. },
  67. success: result => {
  68. if (result.statusCode === 200 && result.data.code === 200) {
  69. Taro.showToast({
  70. title: '发送成功',
  71. icon: 'success',
  72. duration: 2000
  73. })
  74. state.isSmsSent = true
  75. } else {
  76. Taro.showToast({
  77. title: '网络错误',
  78. icon: 'error',
  79. duration: 2000
  80. })
  81. }
  82. },
  83. fail: res => {
  84. console.log(res);
  85. }
  86. })
  87. }
  88. }
  89. </script>
  90. <template>
  91. <view class="h-100 d-flex flex-column">
  92. <BackgroundBasic/>
  93. <NutNavbar title=""></NutNavbar>
  94. <view class="pl-3 pr-3 pt-3 pb-0 d-flex">
  95. <view class="flex-grow-1">
  96. <view class="h3">
  97. <view class="fas fa-chevron-left text-primary" @tap="goBack()" hover-class="btn-hover-primary"/>
  98. </view>
  99. </view>
  100. <view class="d-flex align-items-end">
  101. <View></View>
  102. </view>
  103. </view>
  104. <View class="d-flex flex-column" >
  105. <View class="d-flex justify-content-center">
  106. <Image :src="require('./sms.png')" mode='heightFix' style="height: 30vh"/>
  107. </View>
  108. </View>
  109. <View class="card m-3 mt-5 shadow-lg">
  110. <View class="card-body">
  111. <nut-form>
  112. <nut-form-item>
  113. <view class="d-flex">
  114. <view class="mr-4">
  115. <NutBadge :value="contact.contact.isVIP?'VIP':''">
  116. <NutAvatar size="normal" color="white" :bg-color="BjxHelper.mbString2RgbHex(contact.contact.name)" class="overflow-hidden">
  117. <img v-if="contact.contact.avatar" :src="contact.contact.avatar" />
  118. <view v-else-if="BjxHelper.getBJXFirstChar(contact.contact.name)">{{BjxHelper.getBJXFirstChar(contact.contact.name)}}</view>
  119. <view v-else>
  120. <Text className='fas fa-user fa-lg'/>
  121. </view>
  122. </NutAvatar>
  123. </NutBadge>
  124. </view>
  125. <view class="flex-grow-1">
  126. <view class="d-flex flex-row">
  127. <view v-if="contact.contact.name" class="name text-dark">{{contact.contact.name}}</view>
  128. <view v-else>
  129. <view class="text-black-50 name">
  130. <Text className='text-info fas fa-exclamation-circle'/> 无姓名
  131. </view>
  132. </view>
  133. </view>
  134. <view class="company text-black-50 small">
  135. <view v-if="contact.contact.company">{{contact.contact.company}}</view>
  136. <view v-else>
  137. <Text className='text-info fas fa-exclamation-circle'/> 无公司信息
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. </nut-form-item>
  143. <nut-form-item label="约定到访日期" v-show="!contact.contact.flexVisit">
  144. <view class="d-flex calendar">
  145. <view class="flex-grow-1"></view>
  146. <view class="text-dark" @tap="openSwitch('isDateSelectorVisible')">
  147. {{contact.contact.nextVisitDate ? contact.contact.nextVisitDate : '请选择'}}
  148. </view>
  149. </view>
  150. </nut-form-item>
  151. </nut-form>
  152. </View>
  153. </View>
  154. <view v-if="state.isSmsSent" class="p-3 pb-5">
  155. <nut-button block type="info" @tap="goBack">确认</nut-button>
  156. </view>
  157. <view v-else class="p-3 pb-5">
  158. <nut-button block type="info" @tap="onSmsSend">发送邀约短信</nut-button>
  159. </view>
  160. <nut-calendar
  161. v-model:visible="state.isDateSelectorVisible"
  162. @close="closeSwitch('isDateSelectorVisible')"
  163. @choose="setChooseDate"
  164. :default-value="contact.contact.nextVisitDate"
  165. :is-auto-back-fill="true"
  166. >
  167. </nut-calendar>
  168. </View>
  169. <!-- <view class="p-4">-->
  170. <!-- <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">使用电话号码登录</button>-->
  171. <!-- </view>-->
  172. <!-- <Counter/>-->
  173. <!-- <nut-cell title="展示弹出层" is-link @click="show = true"></nut-cell>-->
  174. <!-- <nut-popup :style="{ padding: '30px 50px' }" v-model:visible="show">正文</nut-popup>-->
  175. <!-- <View><Text>{{state.msg}}</Text></View>-->
  176. <!-- <nut-button type="primary" @click="handleClick(state.msg2)">点我</nut-button>-->
  177. <!-- <Add color="red" />-->
  178. <!-- <div class="alert alert-primary" role="alert">-->
  179. <!-- A simple primary alert—check it out!-->
  180. <!-- </div>-->
  181. <!-- <h1>Example heading <span class="badge bg-secondary">New</span></h1>-->
  182. <!-- <button type="button" class="btn btn-primary">-->
  183. <!-- Notifications <span class="badge text-bg-secondary">4</span>-->
  184. <!-- </button>-->
  185. <!-- <button type="button" class="btn btn-primary position-relative">-->
  186. <!-- Inbox-->
  187. <!-- <span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">-->
  188. <!-- 99+-->
  189. <!-- <span class="visually-hidden">unread messages</span>-->
  190. <!-- </span>-->
  191. <!-- </button>-->
  192. <!-- </view>-->
  193. </template>