addmsg.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <template>
  2. <view>
  3. <!-- 顶部标题栏 -->
  4. <view class="nav-header">
  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. }
  145. },
  146. onShow() {
  147. this.page = 1;
  148. this.loadData();
  149. },
  150. methods: {
  151. copyContent(content){
  152. const eventChannel = this.getOpenerEventChannel();
  153. eventChannel.emit('selectData', content);
  154. uni.navigateBack();
  155. },
  156. // 返回上一页
  157. goBack() {
  158. uni.navigateBack()
  159. },
  160. onPageScroll: function(e) {
  161. this.scrollTop = e.scrollTop > 200;
  162. },
  163. onReachBottom: function() {
  164. this.page = this.page + 1;
  165. this.loadData();
  166. },
  167. onPullDownRefresh: function() {
  168. this.page = 1;
  169. this.loadData();
  170. },
  171. goAdd(index, type, id) {
  172. uni.navigateTo({
  173. url: '/pages/msg/add?type=' + index + '&type1=' + type + '&id=' + id
  174. });
  175. },
  176. //顶部渠道点击
  177. tabClicks(index) {
  178. this.list = [];
  179. this.page = 1;
  180. this.tabCurrentIndex = index;
  181. // this.$queue.showLoading("加载中...")
  182. this.loadData();
  183. },
  184. //获取消息列表
  185. loadData() {
  186. let that = this;
  187. let number = 10;
  188. let token = this.$queue.getData('token');
  189. if (token) {
  190. this.$queue.showLoading("加载中...")
  191. if (this.tabCurrentIndex == 0) {
  192. this.$Request.getT('/app/message/selectMessageByUserId?page=' + this.page + '&limit=' + this
  193. .limit +
  194. '&state=20')
  195. .then(res => {
  196. if (res.code == 0) {
  197. if (this.page == 1) {
  198. this.list = [];
  199. }
  200. res.data.list.forEach(d => {
  201. this.list.push(d);
  202. });
  203. }
  204. uni.hideLoading();
  205. });
  206. } else {
  207. this.$Request.get("/app/user/selectUserById").then(res => {
  208. if (res.code == 0) {
  209. this.contentMsg = res.data.msg ? res.data.msg : '';
  210. }
  211. uni.hideLoading();
  212. });
  213. }
  214. }
  215. },
  216. // 添加常规模板
  217. addRegularTemplate() {
  218. uni.navigateTo({
  219. url: '/pages/msg/regular'
  220. });
  221. },
  222. // 选择模板
  223. selectTemplate(template) {
  224. console.log('选择的模板:', template);
  225. // 这里可以添加使用模板的逻辑,比如跳转到编辑页面
  226. uni.navigateTo({
  227. url: '/pages/msg/add?type=0&type1=0&template=' + encodeURIComponent(template)
  228. });
  229. },
  230. },
  231. onPageScroll: function(e) {
  232. this.scrollTop = e.scrollTop > 200;
  233. },
  234. onReachBottom: function() {
  235. this.page = this.page + 1;
  236. this.loadData();
  237. },
  238. // 自动发送招呼语开关变化
  239. toggleNotification() {
  240. console.log('自动发送招呼语开关状态:', this.notificationEnabled ? '开启' : '关闭');
  241. // 这里可以添加保存到服务器的逻辑
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. .content-area-box{
  247. margin: 40rpx 0;
  248. color: #000000;
  249. background: #FFFFFF;
  250. }
  251. .content-area-edit{
  252. color: rgba(153, 153, 153, 1);
  253. font-family: DM Sans;
  254. font-style: Regular;
  255. font-size: 24rpx;
  256. font-weight: 400;
  257. flex-shrink: 0;
  258. margin-left: 20rpx;
  259. }
  260. page {
  261. padding-top: 80rpx;
  262. }
  263. // 主内容区域
  264. .main-content {
  265. display: flex;
  266. height: calc(78vh);
  267. padding: 0 28rpx;
  268. gap: 20rpx;
  269. }
  270. .bg {
  271. background-color: #FFFFFF;
  272. }
  273. .navbar {
  274. display: flex;
  275. height: 40px;
  276. padding: 0 5px;
  277. background: #FFFFFF;
  278. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  279. position: relative;
  280. z-index: 10;
  281. .nav-item {
  282. flex: 1;
  283. display: flex;
  284. justify-content: center;
  285. align-items: center;
  286. height: 100%;
  287. font-size: 15px;
  288. color: #000000;
  289. position: relative;
  290. &.current {
  291. color: #000000;
  292. &:after {
  293. content: '';
  294. position: absolute;
  295. left: 50%;
  296. bottom: 0;
  297. transform: translateX(-50%);
  298. width: 44px;
  299. height: 0;
  300. border-bottom: 2px solid #016BF6;
  301. }
  302. }
  303. }
  304. }
  305. // 顶部标题栏样式
  306. .nav-header {
  307. height: 80rpx;
  308. display: flex;
  309. align-items: center;
  310. justify-content: space-between;
  311. padding: 0 40rpx;
  312. background: #FFFFFF;
  313. }
  314. .nav-left {
  315. width: 60rpx;
  316. display: flex;
  317. justify-content: flex-start;
  318. }
  319. .nav-center {
  320. flex: 1;
  321. display: flex;
  322. justify-content: center;
  323. }
  324. .nav-title {
  325. font-size: 36rpx;
  326. font-weight: 600;
  327. color: #333333;
  328. }
  329. .nav-right {
  330. width: 60rpx;
  331. display: flex;
  332. justify-content: flex-end;
  333. align-items: center;
  334. }
  335. // 设置项样式
  336. .setting-item {
  337. display: flex;
  338. align-items: center;
  339. justify-content: space-between;
  340. background: #FFFFFF;
  341. border-radius: 12rpx;
  342. &.setting-item-first {
  343. border: none;
  344. padding: 40rpx 28rpx;
  345. }
  346. .setting-left {
  347. display: flex;
  348. flex-direction: column;
  349. align-items: flex-start;
  350. flex: 1;
  351. .setting-title-row {
  352. display: flex;
  353. align-items: center;
  354. justify-content: flex-start;
  355. width: 100%;
  356. margin-bottom: 16rpx;
  357. .setting-label {
  358. color: rgba(21, 22, 26, 1);
  359. font-family: DM Sans;
  360. font-size: 32rpx;
  361. font-weight: 600;
  362. line-height: 26px;
  363. letter-spacing: 0%;
  364. text-align: left;
  365. margin-right: 16rpx;
  366. }
  367. .setting-desc {
  368. color: rgba(153, 153, 153, 1);
  369. font-family: DM Sans;
  370. font-size: 22rpx;
  371. font-weight: 400;
  372. line-height: 13px;
  373. letter-spacing: 0%;
  374. text-align: left;
  375. margin-right: 16rpx;
  376. }
  377. }
  378. .switch-status {
  379. font-size: 32rpx;
  380. &.status-on {
  381. color: #007AFF;
  382. }
  383. &.status-off {
  384. color: #999999;
  385. }
  386. }
  387. }
  388. .setting-right {
  389. display: flex;
  390. align-items: center;
  391. justify-content: flex-end;
  392. .u-switch {
  393. margin-top: 20rpx;
  394. transform: scale(1.2); // 放大开关
  395. }
  396. }
  397. }
  398. // 左侧导航侧边栏
  399. .sidebar {
  400. width: 170rpx;
  401. padding: 20rpx 0;
  402. background: #F8F8F8;
  403. border-radius: 12rpx;
  404. .sidebar-item {
  405. padding: 20rpx 40rpx;
  406. text-align: center;
  407. cursor: pointer;
  408. transition: all 0.3s ease;
  409. &.active {
  410. .sidebar-text {
  411. color: rgba(1, 107, 246, 1);
  412. font-weight: 600;
  413. }
  414. }
  415. .sidebar-text {
  416. font-size: 28rpx;
  417. color: #666666;
  418. font-weight: 400;
  419. }
  420. }
  421. }
  422. // 右侧内容区域
  423. .content-area {
  424. flex: 1;
  425. background: #FFFFFF;
  426. overflow-y: auto;
  427. border-radius: 12rpx;
  428. box-shadow: 0px 8px 150px 0px rgba(0, 0, 0, 0.05);
  429. padding: 20rpx;
  430. }
  431. // 模板项样式
  432. .template-item {
  433. padding: 30rpx 20rpx;
  434. &:active {
  435. color: var(--016BF6, rgba(1, 107, 246, 1));
  436. font-family: DM Sans;
  437. font-size: 16px;
  438. font-weight: 400;
  439. line-height: 21px;
  440. letter-spacing: 0%;
  441. text-align: left;
  442. }
  443. .template-text {
  444. color: rgba(153, 153, 153, 1);
  445. font-family: DM Sans;
  446. font-size: 16px;
  447. font-weight: 400;
  448. line-height: 21px;
  449. letter-spacing: 0%;
  450. text-align: left;
  451. }
  452. }
  453. // 自定义添加按钮样式
  454. .custom-add-button {
  455. margin-top: 80rpx;
  456. display: flex;
  457. align-items: center;
  458. justify-content: center;
  459. color: rgba(1, 107, 246, 1);
  460. font-family: DM Sans;
  461. font-size: 16px;
  462. font-weight: 400;
  463. line-height: 21px;
  464. letter-spacing: 0%;
  465. text-align: left;
  466. &:active {
  467. transform: scale(0.98);
  468. }
  469. }
  470. // 常规添加按钮样式(与自定义按钮样式相同)
  471. .regular-add-button {
  472. display: flex;
  473. align-items: center;
  474. justify-content: center;
  475. color: rgba(1, 107, 246, 1);
  476. font-family: DM Sans;
  477. font-size: 16px;
  478. font-weight: 400;
  479. line-height: 21px;
  480. letter-spacing: 0%;
  481. text-align: left;
  482. &:active {
  483. transform: scale(0.98);
  484. }
  485. }
  486. </style>