add.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <uv-toast ref="toast"></uv-toast>
  3. <view class="titlearea">
  4. <view class="firsttitle">{{$t('member_add_text_1')}}</view>
  5. <view class="title_2">
  6. {{$t('member_add_text_2')}}
  7. <br/>
  8. {{$t('member_add_text_3')}}
  9. </view>
  10. </view>
  11. <view class="memberarea2">
  12. <uv-row class="item">
  13. <uv-col span="7">
  14. <uv-text :text="$t('add_member_text1')"></uv-text>
  15. <!-- <uv-text :text="$t('add_member_text2')"></uv-text> -->
  16. <!-- <uv-text :text="$t('add_member_text3')"></uv-text> -->
  17. </uv-col>
  18. <uv-col span="5">
  19. <uv-row justify="around">
  20. <uv-col span="6" align="center">
  21. <uv-image src="/static/image/selecttype/man.png" shape="circle" width="60" height="60"></uv-image>
  22. <view :class="{paretareabutton_select:selectuser_list[0].selected,addbtn:!selectuser_list[0].selected}" @click="itemselect(1)">
  23. {{ $t('father') }}
  24. </view>
  25. </uv-col>
  26. <uv-col span="6" align="center">
  27. <uv-image src="/static/image/selecttype/woman.png" shape="circle" width="60" height="60"></uv-image>
  28. <view :class="{paretareabutton_select:selectuser_list[1].selected,addbtn:!selectuser_list[1].selected}" @click="itemselect(2)">
  29. {{ $t('mother') }}
  30. </view>
  31. </uv-col>
  32. </uv-row>
  33. </uv-col>
  34. </uv-row>
  35. <uv-line length="80%"></uv-line>
  36. <uv-row class="item">
  37. <uv-col span="7">
  38. <uv-text :text="$t('add_member_text4')"></uv-text>
  39. <!-- <uv-text :text="$t('add_member_text5')"></uv-text> -->
  40. <!-- <uv-text :text="$t('add_member_text6')"></uv-text> -->
  41. </uv-col>
  42. <uv-col span="5">
  43. <uv-row justify="around">
  44. <uv-col span="6" align="center">
  45. <uv-image src="/static/image/selecttype/man.png" shape="circle" width="60" height="60"></uv-image>
  46. <view :class="{paretareabutton_select:selectuser_list[2].selected,addbtn:!selectuser_list[2].selected}" @click="itemselect(3)">
  47. {{ $t('husband') }}
  48. </view>
  49. </uv-col>
  50. <uv-col span="6" align="center">
  51. <uv-image src="/static/image/selecttype/woman.png" shape="circle" width="60" height="60"></uv-image>
  52. <view :class="{paretareabutton_select:selectuser_list[3].selected,addbtn:!selectuser_list[3].selected}" @click="itemselect(4)">
  53. {{ $t('wife') }}
  54. </view>
  55. </uv-col>
  56. </uv-row>
  57. </uv-col>
  58. </uv-row>
  59. </view>
  60. <!-- <view class="memberarea">
  61. <view class="parentarea">
  62. <uv-row>
  63. <uv-col span="7">
  64. <uv-text text="父母有没有"></uv-text>
  65. <uv-text text="心梗脑梗的风险?"></uv-text>
  66. <uv-text text="帮他们评测!"></uv-text>
  67. </uv-col>
  68. <uv-col span="5">
  69. <uv-row justify="around">
  70. <uv-col span="6" align="center">
  71. <uv-image src="/static/image/selecttype/man.png" shape="circle" width="60" height="60"></uv-image>
  72. <view :class="{paretareabutton_select:selectuser_list[0].selected,addbtn:!selectuser_list[0].selected}" @click="itemselect(1)">
  73. {{ $t('father') }}
  74. </view>
  75. </uv-col>
  76. <uv-col span="6" align="center">
  77. <uv-image src="/static/image/selecttype/woman.png" shape="circle" width="60" height="60"></uv-image>
  78. <view :class="{paretareabutton_select:selectuser_list[1].selected,addbtn:!selectuser_list[1].selected}" @click="itemselect(2)">
  79. {{ $t('mother') }}
  80. </view>
  81. </uv-col>
  82. </uv-row>
  83. </uv-col>
  84. </uv-row>
  85. </view>
  86. <view class="parentarea">
  87. <uv-row>
  88. <uv-col span="7">
  89. <uv-text text="爱人工作繁忙"></uv-text>
  90. <uv-text text="应酬多,压力大,常喝酒"></uv-text>
  91. <uv-text text="有没有心脑血管的隐患?"></uv-text>
  92. </uv-col>
  93. <uv-col span="5">
  94. <uv-row justify="around">
  95. <uv-col span="6" align="center">
  96. <uv-image src="/static/image/selecttype/man.png" shape="circle" width="60" height="60"></uv-image>
  97. <view :class="{paretareabutton_select:selectuser_list[2].selected,addbtn:!selectuser_list[2].selected}" @click="itemselect(3)">
  98. {{ $t('husband') }}
  99. </view>
  100. </uv-col>
  101. <uv-col span="6" align="center">
  102. <uv-image src="/static/image/selecttype/woman.png" shape="circle" width="60" height="60"></uv-image>
  103. <view :class="{paretareabutton_select:selectuser_list[3].selected,addbtn:!selectuser_list[3].selected}" @click="itemselect(4)">
  104. {{ $t('wife') }}
  105. </view>
  106. </uv-col>
  107. </uv-row>
  108. </uv-col>
  109. </uv-row>
  110. </view>
  111. </view> -->
  112. <view class='othermember'>
  113. <view class="show_view" @click="setshowdiv">
  114. {{ $t('other_member') }}
  115. </view>
  116. </view>
  117. <view class="selectarea" v-show="showdiv">
  118. <uv-row justify="around">
  119. <uv-col span="6" align="center">
  120. <uv-image src="/static/image/selecttype/man.png" shape="circle" width="100" height="100"></uv-image>
  121. <uv-text :text="$t('add_member_text7')" align="center"></uv-text>
  122. <uv-input :placeholder="$t('add_member_text9')" border="bottom" v-model="other_member_1" customStyle="width:80px"></uv-input>
  123. <view class="paretareabutton_select" @click="addother(1)">
  124. <uv-icon name="plus" color="#fff" size="10"></uv-icon>
  125. </view>
  126. </uv-col>
  127. <uv-col span="6" align="center">
  128. <uv-image src="/static/image/selecttype/woman.png" shape="circle" width="100" height="100"></uv-image>
  129. <uv-text :text="$t('add_member_text8')" align="center"></uv-text>
  130. <uv-input :placeholder="$t('add_member_text9')" border="bottom" v-model="other_member_2" customStyle="width:80px"></uv-input>
  131. <view class="paretareabutton_select" @click="addother(2)">
  132. <uv-icon name="plus" color="#fff" size="10"></uv-icon>
  133. </view>
  134. </uv-col>
  135. </uv-row>
  136. </view>
  137. <view class='buttonarea'>
  138. <uv-button type="primary" shape="square" :text="$t('submit')" customStyle="background:#648EB8;width:80%" @click="addmemberbylist"></uv-button>
  139. </view>
  140. <br />
  141. </template>
  142. <script>
  143. import {subfmemberlistbyuserid,submembergenderbyuserid} from "@/common/api/fmember.js"
  144. export default {
  145. data() {
  146. return {
  147. userinfo:{},
  148. selectuser_list:[
  149. {
  150. title:this.$t('father'),
  151. gender:'1',
  152. selected:false,
  153. },
  154. {
  155. title:this.$t('mother'),
  156. gender:'2',
  157. selected:false,
  158. },
  159. {
  160. title:this.$t('husband'),
  161. gender:'1',
  162. selected:false,
  163. },
  164. {
  165. title:this.$t('wife'),
  166. gender:'2',
  167. selected:false,
  168. },
  169. {
  170. title:'',
  171. gender:'1',
  172. selected:false,
  173. },
  174. {
  175. title:'',
  176. gender:'2',
  177. selected:false,
  178. },
  179. ],
  180. other_member_1:"",
  181. other_member_2:"",
  182. showdiv:false,
  183. memberlist:[],
  184. letcount:0
  185. }
  186. },
  187. methods:{
  188. adduser(){
  189. },
  190. itemselect(index){
  191. this.selectuser_list[index-1].selected =!this.selectuser_list[index-1].selected;
  192. if(index==5){
  193. this.selectuser_list[index-1].title = other_member_1;
  194. }
  195. if(index==6){
  196. this.selectuser_list[index-1].title = other_member_2;
  197. }
  198. },
  199. addother(gender){
  200. let title="";
  201. let fmemberid=this.memberlist.length+1
  202. let subanswerinfo={
  203. userid: this.userinfo.id,
  204. fmemberid:fmemberid,
  205. stemid: 3,
  206. answertype: 1,
  207. }
  208. if(1==gender){
  209. if(this.other_member_1.length<=0){
  210. this.$refs.toast.show({
  211. type: 'error',
  212. message: this.$t('member_title_null')
  213. })
  214. return false
  215. }
  216. title = this.other_member_1
  217. subanswerinfo.answeroption=this.$t('man')
  218. subanswerinfo.answeroptionid=64
  219. }
  220. if(2==gender){
  221. console.log(this.other_member_2,this.other_member_2.length)
  222. if(this.other_member_2.length<=0){
  223. this.$refs.toast.show({
  224. type: 'error',
  225. message: this.$t('member_title_null')
  226. })
  227. return false
  228. }
  229. title = this.other_member_2
  230. subanswerinfo.answeroption=this.$t('female')
  231. subanswerinfo.answeroptionid=65
  232. }
  233. let subanswerlist=[]
  234. subanswerlist.push(subanswerinfo)
  235. var subinfo={
  236. answer: JSON.stringify(subanswerlist),
  237. userid: this.userinfo.id,
  238. fmemberid:this.memberlist.length,
  239. srid: 0,
  240. scaleid: 1,
  241. membername:title,
  242. gender:gender
  243. }
  244. submembergenderbyuserid(subinfo).then(res=>{
  245. res =res.data
  246. if(0==res.code){
  247. this.$refs.toast.show({
  248. type: 'error',
  249. message: res.errmsg
  250. })
  251. }
  252. if(200==res.code){
  253. this.$refs.toast.show({
  254. type: 'success',
  255. message: this.$t('do_success')
  256. })
  257. uni.switchTab({
  258. url: '/pages/index/index'
  259. })
  260. }
  261. });
  262. },
  263. setshowdiv(){
  264. this.showdiv = !this.showdiv;
  265. },
  266. addmemberbylist(){
  267. let selectlist=[]
  268. this.selectuser_list.map(item=>{
  269. if(item.selected){
  270. selectlist.push(item)
  271. }
  272. })
  273. this.letcount = this.memberlist.length-2 +selectlist.length;
  274. if(this.letcount>this.userinfo.fmembercount){
  275. this.$refs.toast.show({
  276. type: 'error',
  277. message: this.$t('member_num_than_max')
  278. })
  279. return false
  280. }
  281. selectlist.map((item,index)=>{
  282. item.fmemberid=this.selectuser_list.length+index
  283. var answerinfo={
  284. userid: this.userinfo.id,
  285. fmemberid:item.fmemberid,
  286. stemid: 3,
  287. answertype: 1,
  288. }
  289. if(item.gender==1){
  290. answerinfo.answeroption=this.$t('man')
  291. answerinfo.answeroptionid=64
  292. }else{
  293. answerinfo.answeroption=this.$t('female')
  294. answerinfo.answeroptionid=65
  295. }
  296. item.answer=JSON.stringify([answerinfo]);
  297. })
  298. let data ={
  299. memberlist:selectlist,
  300. mcount:selectlist.length,
  301. userid: this.userinfo.id,
  302. }
  303. subfmemberlistbyuserid(data).then(res=>{
  304. res =res.data
  305. if(0==res.code){
  306. this.$refs.toast.show({
  307. type: 'error',
  308. message: res.errmsg
  309. })
  310. }
  311. if(200==res.code){
  312. this.$refs.toast.show({
  313. type: 'success',
  314. message: this.$t('do_success')
  315. })
  316. uni.switchTab({
  317. url: '/pages/index/index'
  318. })
  319. }
  320. });
  321. }
  322. },
  323. mounted() {
  324. uni.setNavigationBarTitle({
  325. title: this.$t('add_member')
  326. });
  327. this.userinfo = uni.getStorageSync("userinfo");
  328. this.memberlist=uni.getStorageSync('memberlist');
  329. }
  330. }
  331. </script>
  332. <style scoped>
  333. body{
  334. }
  335. .firsttitle{
  336. font-size:46rpx;
  337. line-height:50rpx;
  338. font-weight:700;
  339. }
  340. .title_2{
  341. margin-top:15rpx;
  342. font-size:36rpx;
  343. font-weight:400;
  344. color:#666666
  345. }
  346. .titlearea{
  347. height:400rpx;
  348. display:flex;
  349. flex-direction:column;
  350. justify-content: center;
  351. align-items:center;
  352. }
  353. .memberarea{
  354. width:100%;
  355. display:flex;
  356. flex-direction:column;
  357. align-items:center;
  358. }
  359. .parentarea{
  360. width:80%;
  361. border-radius:15rpx;
  362. margin-top:10rpx;
  363. margin-bottom:10rpx;
  364. box-shadow:1px 2px 3px 2px rgba(0, 0, 0, 0.3);
  365. padding: 0.5em;
  366. }
  367. .addbtn{
  368. width:100rpx;
  369. height:50rpx;
  370. border-radius:25rpx;
  371. margin-top:10rpx;
  372. margin-bottom:10rpx;
  373. font-size:25rpx;
  374. color:#47689D;
  375. border:1rpx solid #47689d;
  376. display:flex;
  377. justify-content:center;
  378. align-items:center;
  379. }
  380. .paretareabutton_select{
  381. width:100rpx;
  382. height:50rpx;
  383. border-radius:25rpx;
  384. margin-top:10rpx;
  385. margin-bottom:10rpx;
  386. font-size:25rpx;
  387. color:#FFF;
  388. border:1rpx solid #47689d;
  389. background:#47689D;
  390. /*background-color:rgba(245, 154, 35, 1);*/
  391. display:flex;
  392. justify-content:center;
  393. align-items:center;
  394. }
  395. .othermember{
  396. margin-top:20rpx;
  397. width:100%;
  398. display:flex;
  399. justify-content:center;
  400. align-items:center;
  401. }
  402. .othermember .show_view{
  403. width:80%;
  404. height:50rpx;
  405. border:2rpx solid rgba(100, 142, 184, 1);
  406. text-align: center;
  407. padding: 0.5em;
  408. color: rgba(100, 142, 184, 1);
  409. }
  410. .memberarea2{
  411. display:flex;
  412. flex-direction:column;
  413. align-items:center;
  414. }
  415. .memberarea2 .item{
  416. width: 80%;
  417. padding: 1em;
  418. }
  419. .selectarea{
  420. margin-top: 10rpx;
  421. }
  422. .buttonarea{
  423. margin-top:50rpx;
  424. margin-bottom: 5rem;
  425. display:flex;
  426. justify-content:center;
  427. align-items:center;
  428. }
  429. </style>