index.vue 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <view class="my">
  3. <img class="imgMy" src="../../static/images/11.jpg" alt="">
  4. <view class="name_box" v-if="getHasLogin">
  5. <view class="img_box">
  6. <img class="imgs" src="../../static/images/head.png" alt="" />
  7. </view>
  8. <view class="right">
  9. <view class="text_box">
  10. <view class="name" @click="editor">
  11. <text>患友_0001</text>
  12. <image class="name_img" src="../../static/my/2.png" alt="" />
  13. </view>
  14. <view style="">
  15. <text class="sex_box">男</text>
  16. <text class="sex_box">36</text>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- -->
  22. <view class="button_box" v-else>
  23. <button class="butt" open-type="getPhoneNumber" bindtap="getUserProfile" @getphonenumber="wxLogin">登录</button>
  24. </view>
  25. <view class="mainBox">
  26. <view class="shareBox">
  27. <view class="share" @click="toRecord">
  28. <view>
  29. <img src="../../static/my/5.png" alt="" style="width: 56rpx;height: 56rpx;">
  30. <text>我的健康档案</text>
  31. </view>
  32. <img class="rightArrow" src="../../static/images/icon4.png" alt="">
  33. </view>
  34. </view>
  35. <view class="signOut" >
  36. <button class="share" open-type="share" style="width: 100%;padding: 0;">
  37. <view>
  38. <img src="../../static/my/6.png" alt="" style="width: 56rpx;height: 56rpx;">
  39. <text>分享给朋友</text>
  40. </view>
  41. <img class="rightArrow" src="../../static/images/icon4.png" alt="">
  42. </button>
  43. </view>
  44. <view class="signOut" >
  45. <!-- <button class="share" open-type="share" style="width: 100%;padding: 0;"> -->
  46. <view>
  47. <img src="../../static/my/7.png" alt="" style="width: 56rpx;height: 56rpx;">
  48. <text>关于圣卫士</text>
  49. </view>
  50. <img class="rightArrow" src="../../static/images/icon4.png" alt="">
  51. <!-- </button> -->
  52. </view>
  53. </view>
  54. <van-toast id="van-toast" />
  55. </view>
  56. </template>
  57. <script>
  58. import Toast from '@/wxcomponents/vant/toast/toast';
  59. import {
  60. shareMixins
  61. } from '@/mixins/share'
  62. import {
  63. getCode,
  64. login,
  65. getMobile,
  66. getFieldConfig,
  67. getDataConfig,
  68. getKey,
  69. getOrg
  70. } from '@/api/api.js';
  71. import {
  72. mapGetters,
  73. mapMutations
  74. } from 'vuex'
  75. export default {
  76. mixins: [shareMixins],
  77. data() {
  78. return {
  79. userName: "",
  80. shareData: {
  81. title: '分享给朋友',
  82. path: '/pages/index' // 分享的页面路径
  83. },
  84. session_key: '',
  85. phoneNumber: '',
  86. code: '',
  87. loginResCode:'',
  88. appID:'',
  89. orgInfo:'',
  90. dialysis_no:''
  91. }
  92. },
  93. computed: {
  94. ...mapGetters(['getHasLogin', 'getBind'])
  95. },
  96. onLoad() {
  97. const accountInfo = uni.getAccountInfoSync();
  98. this.appID = accountInfo.miniProgram.appId
  99. let that = this
  100. uni.login({
  101. provider:"weixin",
  102. success:(login_res => {
  103. let code = login_res.code;
  104. that.code = code
  105. console.log('that.code',login_res)
  106. that.getKey()
  107. })
  108. })
  109. },
  110. methods: {
  111. ...mapMutations(['setHasLogin','setLogout','setConfigList', 'setFiledList', 'setOrg']),
  112. async getKey(){
  113. let params = {
  114. js_code: this.code
  115. }
  116. let res = await getKey(params)
  117. console.log('key',res.data);
  118. this.session_key = res.data.data.data.session_key
  119. },
  120. async wxLogin(e) {
  121. console.log('111111',e)
  122. const that = this
  123. if(e.detail.errMsg == "getPhoneNumber:ok"){
  124. let params = {
  125. // appid:'wx253b63b84a9c9494',wxcdf53b48b7df107e
  126. appid:'wxcdf53b48b7df107e',
  127. key:this.session_key,
  128. encryptedData:e.detail.encryptedData,
  129. iv:e.detail.iv
  130. }
  131. console.log('222222')
  132. let res = await this.getMobile(params)
  133. console.log('res',res);
  134. if(res.data.data.list != null){
  135. this.phoneNumber = res.data.data.list.phoneNumber
  136. console.log('333333',this.phoneNumber)
  137. this.getLogin(this.phoneNumber)
  138. }else{
  139. Toast('获取失败,重新获取');
  140. }
  141. }else{
  142. Toast('获取失败,重新获取');
  143. }
  144. },
  145. // 健康档案
  146. toRecord(){
  147. if(!this.getHasLogin){
  148. Toast('请先登录');
  149. }else{
  150. if(!this.getBind){
  151. uni.showModal({
  152. title: '未绑定',
  153. content: '是否去绑定',
  154. success: function (res) {
  155. if (res.confirm) {
  156. uni.navigateTo({
  157. url: '/pages/userBinding/index'
  158. })
  159. } else if (res.cancel) {
  160. }
  161. }
  162. });
  163. }else{
  164. uni.navigateTo({
  165. url: '/subpackagesA/pages/medicalRecord/index'
  166. })
  167. }
  168. }
  169. },
  170. async getLogin(mobile){
  171. let params = {
  172. mobile: mobile.toString()
  173. };
  174. let res = await login(params, true)
  175. if(res.data.state == 1){
  176. Toast('登录成功');
  177. }
  178. let data = {
  179. is_bind:res.data.data.is_bind,
  180. userInfo:res.data.data.patient
  181. }
  182. this.setHasLogin(data)
  183. if(res.data.data.patient.id > 0){
  184. this.getDataConfig(res.data.data.patient.id)
  185. this.getFieldConfig(res.data.data.patient.id)
  186. this.getOrg(res.data.data.patient.id)
  187. }
  188. console.log('666666',res.data);
  189. this.userName = res.data.data.role.patient_name
  190. this.dialysis_no= res.data.data.patient.dialysis_no
  191. },
  192. async getMobile(params){
  193. let data = await getMobile(params,true)
  194. return data
  195. },
  196. async getFieldConfig(patient_id){
  197. let params = {
  198. patient_id: patient_id
  199. }
  200. let res = await getFieldConfig(params)
  201. let data = {
  202. filedList:res.data.data
  203. }
  204. console.log('77777',data);
  205. this.setFiledList(data)
  206. },
  207. async getDataConfig(patient_id){
  208. let params = {
  209. patient_id: patient_id
  210. }
  211. let res = await getDataConfig(params)
  212. let data = {
  213. configList:res.data.data.list
  214. }
  215. console.log('88888',data);
  216. this.setConfigList(data)
  217. },
  218. async getOrg(patient_id){
  219. let params = {
  220. patient_id:patient_id
  221. }
  222. let res = await getOrg(params)
  223. this.orgInfo = res.data.data.orgInfo.org_name
  224. },
  225. // 个人信息编辑
  226. editor(){
  227. console.log('个人信息');
  228. wx.navigateTo({
  229. url:'/pages/my/personage'
  230. })
  231. }
  232. },
  233. // 1.发送给朋友
  234. onShareAppMessage(res) {
  235. return {
  236. title: this.shareData.title,
  237. path: this.shareData.path,
  238. // imageUrl: this.share.imageUrl,
  239. }
  240. },
  241. //2.分享到朋友圈
  242. onShareTimeline(res) {
  243. return {
  244. title: this.shareData.title,
  245. path: this.shareData.path,
  246. // imageUrl: this.share.imageUrl,
  247. }
  248. },
  249. }
  250. </script>
  251. <style>
  252. .my {
  253. height: 100%;
  254. }
  255. .imgMy {
  256. width: 100%;
  257. height: 423rpx;
  258. z-index: -2;
  259. }
  260. .shareBox {
  261. width: 670rpx;
  262. background: #FFFFFF;
  263. box-shadow: 0px 14rpx 16rpx 0px rgba(56, 104, 244, 0.07);
  264. border-radius: 14rpx 14rpx 14rpx 14rpx;
  265. margin: 30rpx auto 0;
  266. }
  267. .shareBox button:last-child {
  268. border-bottom: 0;
  269. }
  270. .shareBox view:last-child img {
  271. width: 48rpx;
  272. height: 46rpx;
  273. }
  274. .share {
  275. padding: 0 36rpx;
  276. height: 110rpx;
  277. border-bottom: 1px solid #EBEEF8;
  278. display: flex;
  279. justify-content: space-between;
  280. align-items: center;
  281. background: #FFFFFF;
  282. }
  283. button::after {
  284. border: none;
  285. }
  286. .share view {
  287. display: flex;
  288. align-items: center;
  289. }
  290. .share img {
  291. width: 56rpx;
  292. height: 56rpx;
  293. }
  294. .share text {
  295. font-size: 30rpx;
  296. color: #333333;
  297. margin-left: 20rpx;
  298. }
  299. .rightArrow {
  300. width: 18rpx !important;
  301. height: 30rpx !important;
  302. }
  303. .signOut {
  304. padding: 0 36rpx;
  305. height: 110rpx;
  306. display: flex;
  307. justify-content: space-between;
  308. align-items: center;
  309. width: 670rpx;
  310. margin: 0rpx auto 0;
  311. background: #FFFFFF;
  312. box-shadow: 0px 14rpx 16rpx 0px rgba(56, 104, 244, 0.07);
  313. border-radius: 14rpx 14rpx 14rpx 14rpx;
  314. box-sizing: border-box;
  315. }
  316. .signOut view {
  317. display: flex;
  318. align-items: center;
  319. }
  320. .signOut text {
  321. font-size: 30rpx;
  322. color: #333333;
  323. margin-left: 20rpx;
  324. }
  325. .signOut img {
  326. width: 56rpx;
  327. height: 56rpx;
  328. }
  329. .button_box{
  330. width: 80%;
  331. margin: 0 auto;
  332. }
  333. .butt{
  334. background: linear-gradient(to right,#52c995,#79d5ae);
  335. color: white;
  336. }
  337. </style>
  338. <style lang='scss'>
  339. .name_box{
  340. display: flex;
  341. position: absolute;
  342. top: 15%;
  343. left: 10%;
  344. .img_box{
  345. width:41%;
  346. .imgs{
  347. width: 150rpx;
  348. height: 150rpx;
  349. border-radius: 100rpx;
  350. }
  351. }
  352. .right{
  353. width: 60%;
  354. .text_box{
  355. margin-left: 20rpx;
  356. color: white;
  357. .name{
  358. margin-bottom: 20rpx;
  359. .name_img{
  360. width: 30rpx;height: 40rpx;
  361. }
  362. }
  363. .sex_box{
  364. display: inline-block;
  365. background: #69d9bf;
  366. width: 60rpx;
  367. padding: 10rpx;
  368. margin-right: 10rpx;
  369. border-radius: 20rpx;
  370. text-align: center;
  371. }
  372. }
  373. }
  374. }
  375. </style>