addmsg.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <template>
  2. <view style="height: 100vh;" class="flex flex-direction">
  3. <!-- 顶部标题栏 -->
  4. <view class="nav-header" :style="{ paddingTop: 12 + BarHeight + 'px' }">
  5. <view class="nav-left" @click="goBack">
  6. <u-icon name="close" color="rgba(56, 58, 63, 1)" size="32"></u-icon>
  7. </view>
  8. <view class="nav-center">
  9. <text class="nav-title">常用语</text>
  10. </view>
  11. <view class="nav-right"></view>
  12. </view>
  13. <!-- 招呼语、自动回复切换 -->
  14. <!-- <view class="navbar">
  15. <view v-for="(item, index) in tabList" :key="index" class="nav-item"
  16. :class="{ current: tabCurrentIndex === item.state }" @click="tabClicks(item.state)">
  17. {{ item.text }}
  18. </view>
  19. </view> -->
  20. <!-- 自动回复列表 -->
  21. <!--
  22. <view v-if="tabCurrentIndex == 1 && contentMsg" @click="goAdd(1,1)"
  23. style="margin-top: 20upx;color: #000000;display: flex;align-items: center;background: #FFFFFF;padding: 0rpx 20rpx;">
  24. <view style="height: 80upx;line-height: 80upx;width: 80%;">
  25. {{contentMsg}}
  26. </view>
  27. <view style="width: 20%;display: flex;justify-content: flex-end;">
  28. <image src="../../static/images/my/right_icon.png" style="width: 15rpx;height: 30rpx;"></image>
  29. </view>
  30. </view>
  31. -->
  32. <view v-if="false" class="setting-item setting-item-first">
  33. <view class="setting-left">
  34. <view class="setting-title-row">
  35. <view class="setting-label">自动发送招呼语</view>
  36. <view class="setting-desc">开启后,沟通时自动发送招呼语</view>
  37. </view>
  38. <view class="switch-status" :class="{ 'status-on': notificationEnabled, 'status-off': !notificationEnabled }">
  39. {{ notificationEnabled ? 'On' : 'Off' }}
  40. </view>
  41. </view>
  42. <view class="setting-right">
  43. <u-switch v-model="notificationEnabled" active-color="#007AFF" @change="toggleNotification"></u-switch>
  44. </view>
  45. </view>
  46. <!-- 主内容区域 -->
  47. <view class="main-content">
  48. <!-- 左侧导航侧边栏 -->
  49. <view class="sidebar">
  50. <view hidden class="sidebar-item" :class="{ 'active': tabCurrentIndex === 1 }" @click="tabClicks(1)">
  51. <text class="sidebar-text">常规</text>
  52. </view>
  53. <view class="sidebar-item" :class="{ 'active': tabCurrentIndex === 0 }" @click="tabClicks(0)">
  54. <text class="sidebar-text">自定义</text>
  55. </view>
  56. </view>
  57. <!-- 右侧内容区域 -->
  58. <view class="content-area">
  59. <view v-if="tabCurrentIndex == 0">
  60. <view v-for="item in list" :key="item.id">
  61. <view class="content-area-box flex justify-between">
  62. <view @click="copyContent(item.content)">{{item.content}}</view>
  63. <view class="content-area-edit" @click="goAdd(1, 0, item.id)">
  64. <view>编辑<u-icon name="arrow-right"></u-icon></view>
  65. </view>
  66. </view>
  67. </view>
  68. <!-- 空状态显示 -->
  69. <empty v-if="list.length == 0" content='暂无相关内容'></empty>
  70. <!-- 自定义标签下的添加按钮 -->
  71. <view class="custom-add-button" @click="goAdd(0,0,0)">
  72. 添加常用语
  73. </view>
  74. </view>
  75. <!-- 常规招呼语模板 -->
  76. <view v-if="tabCurrentIndex == 1">
  77. <view class="template-item" @click="selectTemplate('你好')">
  78. <text class="template-text">你好</text>
  79. </view>
  80. <view class="template-item" @click="selectTemplate('Boss, 您好')">
  81. <text class="template-text">Boss, 您好</text>
  82. </view>
  83. <view class="template-item" @click="selectTemplate('你好, 可以聊聊吗?')">
  84. <text class="template-text">你好, 可以聊聊吗?</text>
  85. </view>
  86. <view class="template-item" @click="selectTemplate('我对{招聘职位}很感兴趣, 期望可以深聊, 谢谢!')">
  87. <text class="template-text">我对{招聘职位}很感兴趣, 期望可以深聊, 谢谢!</text>
  88. </view>
  89. <view class="template-item" @click="selectTemplate('你好, 我对贵公司很感兴趣, 希望能和您聊聊!')">
  90. <text class="template-text">你好, 我对贵公司很感兴趣, 希望能和您聊聊!</text>
  91. </view>
  92. <!-- 常规标签下的添加按钮 -->
  93. <view class="regular-add-button" @click="addRegularTemplate()">
  94. <!-- <u-icon name="plus" color="rgba(1, 107, 246, 1)" size="30" style="margin-right: 10upx;"></u-icon> -->
  95. 添加常用语
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <!--
  101. <view class="padding-lr-sm" style="position: fixed;bottom: 40upx;width: 100%;z-index: 99999;"
  102. v-if="tabCurrentIndex == 1 && contentMsg == ''">
  103. <u-button class="" :custom-style="customStyle1" :hair-line="false" @click="goAdd(0,1)">
  104. <u-icon name="plus" color="#fff" size="30" style="margin-right: 10upx;"></u-icon>
  105. 添加
  106. </u-button>
  107. </view>
  108. -->
  109. </view>
  110. </template>
  111. <script>
  112. import empty from '../../components/empty.vue'
  113. export default {
  114. components: {
  115. empty
  116. },
  117. data() {
  118. return {
  119. customStyle1: {
  120. backgroundColor: "#016BF6",
  121. border: 0,
  122. color: "#FFF",
  123. height: '98rpx'
  124. },
  125. contentMsg: '',
  126. tabCurrentIndex: 0,
  127. fromInfo: 5,
  128. limit: 20,
  129. list: [],
  130. page: 1,
  131. scrollTop: false,
  132. notificationEnabled: true, // 自动发送招呼语开关状态
  133. tabList: [{
  134. state: 0,
  135. text: '常用词语',
  136. totalElements: 0
  137. },
  138. {
  139. state: 1,
  140. text: '自动回复',
  141. totalElements: 0
  142. }
  143. ],
  144. BarHeight: '',
  145. }
  146. },
  147. onLoad(){
  148. // #ifdef APP-PLUS
  149. let systemInfo = uni.getSystemInfoSync();
  150. this.BarHeight = systemInfo.statusBarHeight;
  151. // #endif
  152. },
  153. onShow() {
  154. this.page = 1;
  155. this.loadData();
  156. },
  157. methods: {
  158. copyContent(content){
  159. const eventChannel = this.getOpenerEventChannel();
  160. eventChannel.emit('selectData', content);
  161. uni.navigateBack();
  162. },
  163. // 返回上一页
  164. goBack() {
  165. uni.navigateBack()
  166. },
  167. onPageScroll: function(e) {
  168. this.scrollTop = e.scrollTop > 200;
  169. },
  170. onReachBottom: function() {
  171. this.page = this.page + 1;
  172. this.loadData();
  173. },
  174. onPullDownRefresh: function() {
  175. this.page = 1;
  176. this.loadData();
  177. },
  178. goAdd(index, type, id) {
  179. uni.navigateTo({
  180. url: '/pages/msg/add?type=' + index + '&type1=' + type + '&id=' + id
  181. });
  182. },
  183. //顶部渠道点击
  184. tabClicks(index) {
  185. this.list = [];
  186. this.page = 1;
  187. this.tabCurrentIndex = index;
  188. // this.$queue.showLoading("加载中...")
  189. this.loadData();
  190. },
  191. //获取消息列表
  192. loadData() {
  193. let that = this;
  194. let number = 10;
  195. let token = this.$queue.getData('token');
  196. if (token) {
  197. this.$queue.showLoading("加载中...")
  198. if (this.tabCurrentIndex == 0) {
  199. this.$Request.getT('/app/message/selectMessageByUserId?page=' + this.page + '&limit=' + this
  200. .limit +
  201. '&state=20')
  202. .then(res => {
  203. if (res.code == 0) {
  204. if (this.page == 1) {
  205. this.list = [];
  206. }
  207. res.data.list.forEach(d => {
  208. this.list.push(d);
  209. });
  210. }
  211. uni.hideLoading();
  212. });
  213. } else {
  214. this.$Request.get("/app/user/selectUserById").then(res => {
  215. if (res.code == 0) {
  216. this.contentMsg = res.data.msg ? res.data.msg : '';
  217. }
  218. uni.hideLoading();
  219. });
  220. }
  221. }
  222. },
  223. // 添加常规模板
  224. addRegularTemplate() {
  225. uni.navigateTo({
  226. url: '/pages/msg/regular'
  227. });
  228. },
  229. // 选择模板
  230. selectTemplate(template) {
  231. console.log('选择的模板:', template);
  232. // 这里可以添加使用模板的逻辑,比如跳转到编辑页面
  233. uni.navigateTo({
  234. url: '/pages/msg/add?type=0&type1=0&template=' + encodeURIComponent(template)
  235. });
  236. },
  237. },
  238. onPageScroll: function(e) {
  239. this.scrollTop = e.scrollTop > 200;
  240. },
  241. onReachBottom: function() {
  242. this.page = this.page + 1;
  243. this.loadData();
  244. },
  245. // 自动发送招呼语开关变化
  246. toggleNotification() {
  247. console.log('自动发送招呼语开关状态:', this.notificationEnabled ? '开启' : '关闭');
  248. // 这里可以添加保存到服务器的逻辑
  249. }
  250. }
  251. </script>
  252. <style lang="scss" scoped>
  253. .content-area-box{
  254. margin: 40rpx 0;
  255. color: #000000;
  256. background: #FFFFFF;
  257. }
  258. .content-area-edit{
  259. color: rgba(153, 153, 153, 1);
  260. font-family: DM Sans;
  261. font-style: Regular;
  262. font-size: 24rpx;
  263. font-weight: 400;
  264. flex-shrink: 0;
  265. margin-left: 20rpx;
  266. }
  267. // 主内容区域
  268. .main-content {
  269. display: flex;
  270. height: calc(78vh);
  271. padding: 0 28rpx;
  272. gap: 20rpx;
  273. }
  274. .bg {
  275. background-color: #FFFFFF;
  276. }
  277. .navbar {
  278. display: flex;
  279. height: 40px;
  280. padding: 0 5px;
  281. background: #FFFFFF;
  282. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  283. position: relative;
  284. z-index: 10;
  285. .nav-item {
  286. flex: 1;
  287. display: flex;
  288. justify-content: center;
  289. align-items: center;
  290. height: 100%;
  291. font-size: 15px;
  292. color: #000000;
  293. position: relative;
  294. &.current {
  295. color: #000000;
  296. &:after {
  297. content: '';
  298. position: absolute;
  299. left: 50%;
  300. bottom: 0;
  301. transform: translateX(-50%);
  302. width: 44px;
  303. height: 0;
  304. border-bottom: 2px solid #016BF6;
  305. }
  306. }
  307. }
  308. }
  309. // 顶部标题栏样式
  310. .nav-header {
  311. line-height: 26px;
  312. display: flex;
  313. align-items: center;
  314. justify-content: space-between;
  315. padding: 24rpx 32rpx 20rpx 32rpx;
  316. background: #FFFFFF;
  317. }
  318. .nav-left {
  319. width: 60rpx;
  320. display: flex;
  321. justify-content: flex-start;
  322. }
  323. .nav-center {
  324. flex: 1;
  325. display: flex;
  326. justify-content: center;
  327. }
  328. .nav-title {
  329. font-size: 36rpx;
  330. font-weight: 600;
  331. color: #333333;
  332. }
  333. .nav-right {
  334. width: 60rpx;
  335. display: flex;
  336. justify-content: flex-end;
  337. align-items: center;
  338. }
  339. // 设置项样式
  340. .setting-item {
  341. display: flex;
  342. align-items: center;
  343. justify-content: space-between;
  344. background: #FFFFFF;
  345. border-radius: 12rpx;
  346. &.setting-item-first {
  347. border: none;
  348. padding: 40rpx 28rpx;
  349. }
  350. .setting-left {
  351. display: flex;
  352. flex-direction: column;
  353. align-items: flex-start;
  354. flex: 1;
  355. .setting-title-row {
  356. display: flex;
  357. align-items: center;
  358. justify-content: flex-start;
  359. width: 100%;
  360. margin-bottom: 16rpx;
  361. .setting-label {
  362. color: rgba(21, 22, 26, 1);
  363. font-family: DM Sans;
  364. font-size: 32rpx;
  365. font-weight: 600;
  366. line-height: 26px;
  367. letter-spacing: 0%;
  368. text-align: left;
  369. margin-right: 16rpx;
  370. }
  371. .setting-desc {
  372. color: rgba(153, 153, 153, 1);
  373. font-family: DM Sans;
  374. font-size: 22rpx;
  375. font-weight: 400;
  376. line-height: 13px;
  377. letter-spacing: 0%;
  378. text-align: left;
  379. margin-right: 16rpx;
  380. }
  381. }
  382. .switch-status {
  383. font-size: 32rpx;
  384. &.status-on {
  385. color: #007AFF;
  386. }
  387. &.status-off {
  388. color: #999999;
  389. }
  390. }
  391. }
  392. .setting-right {
  393. display: flex;
  394. align-items: center;
  395. justify-content: flex-end;
  396. .u-switch {
  397. margin-top: 20rpx;
  398. transform: scale(1.2); // 放大开关
  399. }
  400. }
  401. }
  402. // 左侧导航侧边栏
  403. .sidebar {
  404. width: 170rpx;
  405. padding: 20rpx 0;
  406. background: #F8F8F8;
  407. border-radius: 12rpx;
  408. .sidebar-item {
  409. padding: 20rpx 40rpx;
  410. text-align: center;
  411. cursor: pointer;
  412. transition: all 0.3s ease;
  413. &.active {
  414. .sidebar-text {
  415. color: rgba(1, 107, 246, 1);
  416. font-weight: 600;
  417. }
  418. }
  419. .sidebar-text {
  420. font-size: 28rpx;
  421. color: #666666;
  422. font-weight: 400;
  423. }
  424. }
  425. }
  426. // 右侧内容区域
  427. .content-area {
  428. flex: 1;
  429. background: #FFFFFF;
  430. overflow-y: auto;
  431. border-radius: 12rpx;
  432. box-shadow: 0px 8px 150px 0px rgba(0, 0, 0, 0.05);
  433. padding: 20rpx;
  434. }
  435. // 模板项样式
  436. .template-item {
  437. padding: 30rpx 20rpx;
  438. &:active {
  439. color: var(--016BF6, rgba(1, 107, 246, 1));
  440. font-family: DM Sans;
  441. font-size: 16px;
  442. font-weight: 400;
  443. line-height: 21px;
  444. letter-spacing: 0%;
  445. text-align: left;
  446. }
  447. .template-text {
  448. color: rgba(153, 153, 153, 1);
  449. font-family: DM Sans;
  450. font-size: 16px;
  451. font-weight: 400;
  452. line-height: 21px;
  453. letter-spacing: 0%;
  454. text-align: left;
  455. }
  456. }
  457. // 自定义添加按钮样式
  458. .custom-add-button {
  459. margin-top: 80rpx;
  460. display: flex;
  461. align-items: center;
  462. justify-content: center;
  463. color: rgba(1, 107, 246, 1);
  464. font-family: DM Sans;
  465. font-size: 16px;
  466. font-weight: 400;
  467. line-height: 21px;
  468. letter-spacing: 0%;
  469. text-align: left;
  470. &:active {
  471. transform: scale(0.98);
  472. }
  473. }
  474. // 常规添加按钮样式(与自定义按钮样式相同)
  475. .regular-add-button {
  476. display: flex;
  477. align-items: center;
  478. justify-content: center;
  479. color: rgba(1, 107, 246, 1);
  480. font-family: DM Sans;
  481. font-size: 16px;
  482. font-weight: 400;
  483. line-height: 21px;
  484. letter-spacing: 0%;
  485. text-align: left;
  486. &:active {
  487. transform: scale(0.98);
  488. }
  489. }
  490. </style>