index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <view>
  3. <nav-bar></nav-bar>
  4. <view>
  5. <image class="indexHeader" src="/static/index_hader.png"></image>
  6. </view>
  7. <view class="content">
  8. <view class="userBox">
  9. <view @click="toNavigator('/pages/reviseUserInfo/reviseUserInfo',1)">
  10. <open-data type="userAvatarUrl" class="userImg"></open-data>
  11. </view>
  12. <view class="right" v-if="haveUserInfo">
  13. <view>
  14. <text class="userName">{{userinfo.name ? userinfo.name : ''}}</text>
  15. </view>
  16. <text class="cre_num">档案号: <text class="userTeam">{{userinfo.cre_num ? userinfo.cre_num : ''}}</text></text>
  17. <text>所&emsp;属:<text class="userTeam">{{userinfo.teamname ? userinfo.teamname : '无团队'}}</text></text>
  18. </view>
  19. </view>
  20. <view class="msgBox">
  21. <image class="msgTitle" src="/static/msg_title.png"></image>
  22. <swiper v-if="msgList.length>0"
  23. class="msgContent"
  24. :indicator-dots="swiper.indicatorDots"
  25. :autoplay="swiper.autoplay"
  26. :interval="swiper.interval"
  27. :duration="swiper.duration"
  28. :vertical="swiper.vertical"
  29. >
  30. <swiper-item class="swiper-item">
  31. <navigator v-for="item in msgList" v-bind:key="item.id" :url="`/pages/msgInfo/msgInfo?id=${item.id}`">
  32. <text class="messageInfo">{{item.title}}</text>
  33. </navigator>
  34. </swiper-item>
  35. </swiper>
  36. <text v-else class="msgContent">暂无公告信息</text>
  37. <view @click="toNavigator('/pages/msgList/msgList')">
  38. <image class="msgTitle2" src="/static/msg_title_2.png"></image>
  39. </view>
  40. </view>
  41. <view class="routerBox">
  42. <view class="router_item" @tap="toNavigator('/pages/pay/pay')">
  43. <image class="router_item_img" src="/static/router_1.jpg"></image>
  44. </view>
  45. <view class="router_item" @tap="toNavigator('/pages/payList/payList')">
  46. <image class="router_item_img" src="/static/router_2.jpg"></image>
  47. </view>
  48. <view class="router_item" @tap="toNavigator('/pages/promise/promise')">
  49. <image class="router_item_img" src="/static/router_3.jpg"></image>
  50. </view>
  51. <view class="router_item" @tap="toNavigator('/pages/team/team')">
  52. <image class="router_item_img" src="/static/router_4.jpg"></image>
  53. </view>
  54. <view class="router_item" @tap="toNavigator('/pages/help/help')">
  55. <image class="router_item_img" src="/static/router_5.jpg"></image>
  56. </view>
  57. <view class="router_item" @tap="toNavigator('/pages/feedback/feedback')">
  58. <image class="router_item_img" src="/static/router_6.png"></image>
  59. </view>
  60. </view>
  61. </view>
  62. <auth
  63. ref="authDialog"
  64. @closeAuth="closeAuth"
  65. >
  66. </auth>
  67. </view>
  68. </template>
  69. <script>
  70. import Auth from "../../components/Auth.vue"
  71. import { getToken, messageList,userInfo } from "../../api/index.js"
  72. import { mapState } from "vuex"
  73. export default {
  74. data() {
  75. return {
  76. msgList:[],
  77. msg:"",
  78. authType:false,
  79. swiper:{
  80. indicatorDots: false,
  81. autoplay: true,
  82. interval: 2000,
  83. duration: 500,
  84. vertical: true
  85. },
  86. haveUserInfo: false
  87. }
  88. },
  89. components:{
  90. Auth
  91. },
  92. computed:{
  93. ...mapState(["userinfo"])
  94. },
  95. onShareAppMessage(res) {
  96. return {
  97. title: '723缴费小程序',
  98. path: '/pages/index/index'
  99. }
  100. },
  101. created(){
  102. const that=this
  103. uni.$on("haveUserInfo",()=>{
  104. that.haveUserInfo=true
  105. })
  106. },
  107. async onLoad(){
  108. const that=this
  109. uni.showLoading()
  110. const [,{code}]=await uni.login()
  111. getToken({
  112. code
  113. }).then(g_res=>{
  114. uni.hideLoading()
  115. // 存在cert 证明没有认证
  116. if(g_res.cert){
  117. const { cert,openid }=g_res
  118. that.$store.commit("change_openid",openid);
  119. that.$refs.authDialog.handleOpen()
  120. // 是否认证,是否确认团队
  121. uni.setStorage({
  122. key:"isSure",
  123. data:0
  124. })
  125. }else{
  126. if(uni.getStorageSync("isSure")){
  127. that.$refs.authDialog.handleSure()
  128. that.$refs.authDialog.handleTeam()
  129. that.$refs.authDialog.handleOpen()
  130. }else{
  131. const { token,openid } = g_res
  132. that.$store.commit("change_token",token);
  133. that.$store.commit("change_openid",openid);
  134. uni.setStorage({
  135. key:"token",
  136. data:token
  137. })
  138. setTimeout(()=>{
  139. that.$store.dispatch("getUser");
  140. that.getMessageList()
  141. },123)
  142. }
  143. }
  144. }).catch(e=>{
  145. uni.hideLoading()
  146. })
  147. },
  148. methods: {
  149. // 获取公告信息
  150. getMessageList(){
  151. const that=this
  152. messageList({
  153. page_index:1,
  154. page_size:1
  155. }).then(res=>{
  156. try{
  157. const {data} = res
  158. that.msgList=data
  159. }catch(e){
  160. that.msgList=[]
  161. }
  162. })
  163. },
  164. // 跳转
  165. toNavigator(url,type=0){
  166. const that=this
  167. this.$store.commit('CHANGE_UPDATEUSER',true)
  168. that.$store.dispatch("getUser");
  169. if(type==0){
  170. if(!that.userinfo.team_id || that.userinfo.team_id===0){
  171. uni.showToast({
  172. title:"请联系您的队长,添加团队",
  173. icon:"none"
  174. })
  175. return false;
  176. }
  177. }
  178. uni.getStorage({
  179. key:"token",
  180. success:function(res){
  181. if(res){
  182. uni.navigateTo({
  183. url
  184. })
  185. }else{
  186. that.authType = false
  187. that.$refs.authDialog.handleOpen()
  188. }
  189. },
  190. fail:function(){
  191. that.authType = false
  192. that.$refs.authDialog.handleOpen()
  193. }
  194. })
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss">
  200. page{
  201. width: 100%;
  202. height: 100%;
  203. background: $uni-bg-color-normal;
  204. }
  205. .indexHeader{
  206. display: block;
  207. width: 100%;
  208. height: 248rpx;
  209. }
  210. .content{
  211. width: 661rpx;
  212. margin: 0 auto;
  213. }
  214. .userBox{
  215. width: 100%;
  216. height: 169rpx;
  217. background-color: $uni-bg-color;
  218. border-radius: 4px;
  219. margin-top: -60rpx;
  220. display: flex;
  221. align-items: center;
  222. justify-content: space-between;
  223. font-size: 24rpx;
  224. color: #4D4D4D;
  225. .right{
  226. width: calc(100% - 96rpx - 66rpx);
  227. display: flex;
  228. justify-content: space-between;
  229. // align-items: flex-start;
  230. flex-direction: column;
  231. .userName{
  232. margin-right: 33rpx;
  233. font-weight: bolder;
  234. color: #1971F2;
  235. font-size: 30rpx;
  236. margin-bottom: 5rpx;
  237. display: block;
  238. overflow: hidden;
  239. text-overflow: ellipsis;
  240. white-space: nowrap;
  241. }
  242. .info{
  243. height: 86rpx;
  244. display: flex;
  245. justify-content: space-between;
  246. flex-direction: column;
  247. font-size: 26rpx;
  248. padding: 5rpx 0;
  249. }
  250. }
  251. }
  252. .userImg{
  253. display: block;
  254. width: 96rpx;
  255. height: 96rpx;
  256. border-radius: 50%;
  257. border: 2px solid #BFBFBF;
  258. margin-left: 33rpx;
  259. margin-right: 33rpx;
  260. overflow: hidden;
  261. }
  262. .userTeam{
  263. margin-left: 25rpx;
  264. display: inline-block;
  265. }
  266. .msgBox{
  267. width: calc(100% - 44rpx);
  268. height: 100rpx;
  269. background-color: $uni-bg-color;
  270. margin: 38rpx 0 55rpx 0;
  271. display: flex;
  272. align-items: center;
  273. padding: 0 22rpx;
  274. }
  275. .msgTitle{
  276. display: block;
  277. width: 59rpx;
  278. height: 28rpx;
  279. }
  280. .msgTitle2{
  281. display: block;
  282. width: 72rpx;
  283. height: 35rpx;
  284. }
  285. .msgContent{
  286. width: calc(100% - 161rpx - 1px);
  287. padding: 0 15rpx;
  288. font-size: 26rpx;
  289. color: #4D4D4D;
  290. overflow:hidden;
  291. text-overflow:ellipse;
  292. display:flex;
  293. align-items: center;
  294. justify-content: space-between;
  295. height: 100rpx;
  296. }
  297. .msgContent::after{
  298. content: "";
  299. display: block;
  300. width: 1px;
  301. height: 60rpx;
  302. background: url(../../static/msg_border_left.png);
  303. background-size: cover;
  304. }
  305. .routerBox{
  306. display: flex;
  307. justify-content: flex-start;
  308. flex-wrap: wrap;
  309. width: 100%;
  310. }
  311. .router_item{
  312. width: 180rpx;
  313. height: 180rpx;
  314. margin-bottom: 37rpx;
  315. }
  316. .router_item_img{
  317. width: 100%;
  318. height: 100%;
  319. }
  320. .router_item:nth-of-type(2),.router_item:nth-of-type(5){
  321. margin: 0 55rpx;
  322. }
  323. .swiper-item{
  324. line-height: 100rpx;
  325. }
  326. .messageInfo{
  327. display: block;
  328. white-space:nowrap;
  329. height: 100rpx !important;
  330. width: 100%;
  331. overflow: hidden ;
  332. text-overflow:ellipsis;
  333. }
  334. </style>