addmsg.vue 12 KB

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