add.vue 12 KB

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