service.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="content">
  3. <view class="service-header">
  4. <view class="tips">欢迎来到奥莱优品</view>
  5. <view class="title">需要一点帮助?</view>
  6. <view class="tips">售前、售后问题,随时为您解答</view>
  7. </view>
  8. <scroll-view class="service-body" scroll-y scroll-with-animation>
  9. <view class="body-list">
  10. <view class="title">
  11. <view class="title-tips">Message center</view>
  12. <view class="name">聊天列表</view>
  13. </view>
  14. <view class="empty-chat" v-if="dataList.length == 0">
  15. <view class="imgs">
  16. <image src="/static/image/empty.png" mode="widthFix"></image>
  17. <view class="tip">通过首页、订单、商品中可发起客服咨询</view>
  18. </view>
  19. <view class="re-btn" @click="toHome" v-if="isLogin">去下单</view>
  20. <view class="re-btn" @click="toLogin" v-else>立即登录</view>
  21. </view>
  22. <view class="list-service" v-else>
  23. <view class="service-item" @click="toChat" v-for="(item,index) in dataList" :key="index">
  24. <view class="avatar"><image :src="item.avatar"></image></view>
  25. <view class="info">
  26. <view class="name">{{ item.poi_name }}</view>
  27. <view class="desc" v-if="item.last.type=='text'">{{item.last.content}}</view>
  28. <view class="desc" v-if="item.last.type=='order'">[订单消息]</view>
  29. <view class="desc" v-if="item.last.type=='image'">[图片消息]</view>
  30. <view class="desc" v-if="item.last.type=='video'">[视频消息]</view>
  31. <view class="desc" v-if="item.last.type=='pay'">[支付消息]</view>
  32. <view class="desc" v-if="item.last.type=='address'">[地址消息]</view>
  33. </view>
  34. <view class="time">{{ item.last.create_at }}</view>
  35. </view>
  36. </view>
  37. </view>
  38. </scroll-view>
  39. <halfLogin ref="loginCom" @success="loginSuccess"></halfLogin>
  40. </view>
  41. </template>
  42. <script>
  43. var app;
  44. export default {
  45. data() {
  46. return {
  47. dataList:[],
  48. isLogin:true,
  49. userState:1
  50. }
  51. },
  52. onLoad() {
  53. app = this;
  54. app.getService()
  55. },
  56. methods: {
  57. loginSuccess(){
  58. app.getService()
  59. },
  60. toLogin(){
  61. app.$refs.loginCom.open(1);
  62. },
  63. async getService(){
  64. var formData = {};
  65. formData.page = 1;
  66. formData.size = 100;
  67. const tokenPoi = uni.getStorageSync("contact");
  68. formData.poi = tokenPoi.poi_id;
  69. var res = await app.$api.chat.list.get(formData);
  70. uni.hideLoading();
  71. if (res.code == 401) {
  72. app.isLogin = false;
  73. return ;
  74. }
  75. if (res.code == 0) {
  76. return app.$dialog.showSuccess(res.msg);
  77. }
  78. app.isLogin = true;
  79. app.dataList = res.data.data.rows;
  80. app.userState = res.data.user;
  81. },
  82. toChat(){
  83. if (app.userState == 0) {
  84. app.$refs.loginCom.open(2);
  85. return ;
  86. }
  87. uni.navigateTo({
  88. url:"/pages/service/chat"
  89. })
  90. },
  91. toHome(){
  92. uni.switchTab({
  93. url:"/pages/index/index"
  94. })
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .content{
  101. position: fixed;
  102. z-index: 1;
  103. top: 0;
  104. left: 0;
  105. bottom: 0;
  106. right: 0;
  107. background-color: #ededed;
  108. display: flex;
  109. flex-direction: column;
  110. }
  111. .empty-chat{
  112. display: flex;align-items: center;justify-content: center;flex-direction: column;
  113. height: 50vh;
  114. .imgs{
  115. text-align: center;font-size: 28upx;color: #666;
  116. image{height: 160upx;width: 160upx;}
  117. .tip{margin-top: 20upx;}
  118. }
  119. .re-btn{
  120. width: 180upx;
  121. height: 80upx;
  122. line-height: 80upx;
  123. text-align: center;
  124. font-size: 28upx;
  125. color: #fff;
  126. background-color: $main-color;
  127. border-radius: 10upx;
  128. margin-top: 60upx;
  129. }
  130. }
  131. .service-header{
  132. background-color: $main-color;
  133. padding: 20rpx;
  134. .tips{
  135. color: $main-sub-color;
  136. font-size: 28rpx;line-height: 48rpx;
  137. }
  138. .title{
  139. font-size: 46rpx;
  140. color: #fff;
  141. font-weight: 900;
  142. margin: 10rpx 0;
  143. }
  144. }
  145. .service-body{
  146. height: 0;
  147. flex: 1;
  148. .body-list{
  149. width: 95%;
  150. margin: 20rpx auto;
  151. .title {
  152. .title-tips{
  153. color: $main-color;
  154. font-weight: 700;
  155. font-size: 24rpx;
  156. text-transform: uppercase;
  157. }
  158. .name {
  159. font-size: 38rpx;
  160. color: #333;
  161. font-weight: 900;
  162. }
  163. }
  164. .list-service {
  165. .service-item{
  166. display: flex;
  167. align-items: center;
  168. background-color: #fff;
  169. border-radius: 20rpx;
  170. margin-top: 20rpx;
  171. padding: 20rpx;
  172. gap: 20rpx;
  173. image {
  174. width: 100rpx;
  175. height: 100rpx;
  176. border-radius: 10rpx;
  177. border: 2rpx solid #f8f8f8;
  178. }
  179. .name {
  180. font-size: 32rpx;
  181. font-weight: 600;
  182. color: #333;
  183. }
  184. .desc {
  185. color: $main-text-color;
  186. font-size: 26rpx;
  187. margin-top: 10rpx;
  188. }
  189. .time {
  190. margin-left: auto;
  191. margin-right: 0;
  192. color: $main-text-color;
  193. font-size: 26rpx;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. </style>