index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="main">
  3. <!--轮播图-->
  4. <view class="banner">
  5. <u-swiper circular :radius="5" :indicator="true" keyName="pic" :list="bannerList" :height="150" class="uni-swiper" @click="click"></u-swiper>
  6. </view>
  7. <!--通知公告-->
  8. <view class="notice">
  9. <u-notice-bar color="#848484" :text="noticeList" :step="true" direction="column" mode="link" bgColor="white" speed="300" url="/pages/notice/index"></u-notice-bar>
  10. </view>
  11. <view class="flow">
  12. <!--实名认证-->
  13. <view class="item" @click="go('auth')">
  14. <view class="out">
  15. <view class="int">
  16. <view class="icon tb" style="color: rgb(72, 154, 253)">&#xe600;</view>
  17. <view class="con">
  18. <view class="bt">实名认证</view>
  19. <view class="zt">{{ !user.isAuthentication || user.isAuthentication == 0 ? '尚未提交资料' : '已认证' }}</view>
  20. </view>
  21. <view class="state" v-if="!user.isAuthentication || user.isAuthentication === 0">
  22. <view class="go">去认证</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <!--关联企业-->
  28. <view class="item" @click="go('company')">
  29. <view class="out">
  30. <view class="int">
  31. <view class="icon tb" style="color: rgb(250, 178, 46)">&#xe623;</view>
  32. <view class="con">
  33. <view class="bt">关联企业</view>
  34. <view class="zt">{{ !user.isCompany || user.isCompany == 0 ? '尚未关联企业' : '已关联' }} {{ user.isCompany > 0 ? user.isCompany + '家' : '' }}</view>
  35. </view>
  36. <view class="state" v-if="!user.isCompany || user.isCompany == 0">
  37. <view class="go" :style="{ backgroundColor: user.isAuthentication === 1 ? '#5a7afc' : '#d6d6d6' }">去关联</view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <!--电子签约-->
  43. <view class="item" @click="go('contract')">
  44. <view class="out">
  45. <view class="int">
  46. <view class="icon tb" style="color: rgb(255, 87, 34)">&#xe6ed;</view>
  47. <view class="con">
  48. <view class="bt">电子签约</view>
  49. <view class="zt">{{ !user.isContract || user.isContract == 0 ? '尚未签约' : '已签约' }}</view>
  50. </view>
  51. <view class="state">
  52. <view class="go" :style="{ backgroundColor: user.isCompany > 0 ? '#5a7afc' : '#d6d6d6' }" v-if="!user.isContract || user.isContract == 0">去签约</view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <!--开始接包-->
  58. <view class="item" @click="go('packages')">
  59. <view class="out">
  60. <view class="int">
  61. <view class="icon tb" style="color: rgb(250, 83, 118)">&#xe604;</view>
  62. <view class="con">
  63. <view class="bt">开始接包</view>
  64. <view class="zt">{{ !user.isCompany || user.isCompany == 0 ? '请先签约' : '去接包' }}</view>
  65. </view>
  66. <view class="state">
  67. <view class="go" :style="{ backgroundColor: user.isCompany > 0 && user.isContract == 1 ? '#5a7afc' : '#d6d6d6' }" v-if="!user.isCompany || user.isCompany == 0 || user.isContract == 0">去接包</view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <u-action-sheet round="20" :actions="actions" @select="selectClick" cancelText="取消" :show="show" @close="show = false"></u-action-sheet>
  74. <signature ref="sig" @sign="sign"></signature>
  75. </view>
  76. </template>
  77. <script>
  78. export default {
  79. data() {
  80. return {
  81. ip: this.http.ip,
  82. user: {},
  83. bannerList: [],
  84. noticeList: [],
  85. contract: {},
  86. show: false,
  87. actions: [{ name: '查看合同' }, { name: '去签字' }]
  88. };
  89. },
  90. onShow() {
  91. if (this.hasLogin()) {
  92. this.getUserInfo();
  93. }
  94. },
  95. onLoad() {
  96. this.getData();
  97. },
  98. methods: {
  99. getUserInfo() {
  100. this.http.request({
  101. url: '/app/user/info',
  102. success: (res) => {
  103. this.user = res.data.data;
  104. }
  105. });
  106. },
  107. getData() {
  108. this.http.request({
  109. url: '/app/home/index',
  110. success: (res) => {
  111. this.contract = res.data.data.contract;
  112. this.bannerList = res.data.data.bannerList;
  113. res.data.data.noticeList.forEach((item) => {
  114. this.noticeList.push(item.title);
  115. });
  116. }
  117. });
  118. },
  119. go(url) {
  120. if (this.hasLogin()) {
  121. if (url == 'auth') {
  122. uni.navigateTo({ url: '/pages/auth/index' });
  123. }
  124. if (url == 'company' && this.user.isAuthentication === 1) {
  125. uni.navigateTo({ url: '/pages/company/index' });
  126. }
  127. if (url == 'packages' && this.user.isCompany > 0 && this.user.isContract == 1) {
  128. uni.switchTab({ url: '/pages/packages/index' });
  129. }
  130. if (url == 'contract' && this.user.isContract == 1) {
  131. this.look();
  132. }
  133. if (url == 'contract' && this.user.isContract == 0) {
  134. this.show = true;
  135. }
  136. } else {
  137. uni.navigateTo({ url: '/pages/user/login' });
  138. }
  139. },
  140. selectClick(e) {
  141. if (e.name == '查看合同') {
  142. this.look();
  143. } else {
  144. this.$refs.sig.getSyncSignature();
  145. }
  146. },
  147. //查看合同
  148. look() {
  149. uni.showLoading({ title: '正在打开合同...', mask: true });
  150. uni.downloadFile({
  151. url: this.user.isContract == 0 ? this.ip + this.contract.url : this.ip + '/app/contract/look',
  152. header: { Authorization: this.getUser().token },
  153. success: (res) => {
  154. uni.openDocument({
  155. filePath: res.tempFilePath,
  156. showMenu: true,
  157. success: (res) => {
  158. uni.hideLoading();
  159. }
  160. });
  161. },
  162. fail: (res) => {
  163. uni.hideLoading();
  164. }
  165. });
  166. },
  167. //电子签名
  168. sign(val) {
  169. this.http.request({
  170. url: '/app/contract/add',
  171. data: { contractId: this.contract.id, url: val },
  172. method: 'POST',
  173. success: (res) => {
  174. uni.showModal({
  175. title: '提示',
  176. content: '签约成功',
  177. showCancel: false,
  178. success: (res) => {
  179. this.getUserInfo();
  180. }
  181. });
  182. }
  183. });
  184. }
  185. }
  186. };
  187. </script>
  188. <style lang="scss">
  189. .main {
  190. padding: 5px 15px 15px 15px;
  191. }
  192. .banner {
  193. }
  194. .notice {
  195. margin-top: 10px;
  196. margin-bottom: -10px;
  197. }
  198. .flow {
  199. padding-top: 20px;
  200. .title {
  201. font-size: 15px;
  202. margin-bottom: 10px;
  203. }
  204. .item {
  205. border-radius: 10px;
  206. overflow: hidden;
  207. float: left;
  208. width: 50%;
  209. .out {
  210. padding: 5px;
  211. .int {
  212. padding: 15px;
  213. background-color: white;
  214. overflow: hidden;
  215. border-radius: 9px;
  216. text-align: center;
  217. .tb {
  218. margin: 0 auto;
  219. width: 40px;
  220. height: 40px;
  221. padding: 10px;
  222. line-height: 39px;
  223. color: $main-color;
  224. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  225. border-radius: 50%;
  226. font-size: 27px;
  227. }
  228. .con {
  229. padding-top: 8px;
  230. .bt {
  231. font-size: 18px;
  232. }
  233. .zt {
  234. font-size: 13px;
  235. padding-top: 5px;
  236. color: #909090;
  237. }
  238. }
  239. .state {
  240. padding-top: 11px;
  241. .zt {
  242. font-size: 13px;
  243. color: $main-color;
  244. }
  245. .icon {
  246. color: #909090;
  247. }
  248. .go {
  249. padding: 5px 12px;
  250. font-size: 14px;
  251. background-color: #5a7afc;
  252. color: white;
  253. border-radius: 20px;
  254. }
  255. }
  256. }
  257. }
  258. }
  259. }
  260. </style>