common.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <uv-toast ref="toast"></uv-toast>
  3. <view class="">
  4. <navbar :title="$t('scale_evaluation')" size="48" :backtext="$t('back')" color="#fff"></navbar>
  5. </view>
  6. <view class="app_content">
  7. <view class='titlearea'>
  8. <text class='title_2'>{{$t('completion_problem_for_valuating_people')}}</text>
  9. <text class='title_member'>{{$t('valuating_people')}}:{{selectuser.membername}}</text>
  10. </view>
  11. <view class="info_div">
  12. <view class="text_div">
  13. <view class="title1">{{stemitem.stem}}</view>
  14. </view>
  15. <view class="text_div">
  16. <view class="title2">{{stemitem.disstr}}</view>
  17. </view>
  18. </view>
  19. <view class="info_div">
  20. <view class="" v-if="1==stemitem.stemtype">
  21. <!-- 单选 -->
  22. </view>
  23. <view class="" v-if="2==stemitem.stemtype">
  24. <!-- 多选 -->
  25. </view>
  26. <!-- <uv-radio-group v-model="selectanswer" placement="column" @change="change" >
  27. <uv-radio
  28. shape="square"
  29. iconSize="30"
  30. labelSize="30"
  31. size="30"
  32. :customStyle="{margin: '10px'}"
  33. v-for="(item, index) in stemitem.alist"
  34. :key="index"
  35. :name="item">
  36. <slot name="default">
  37. <text class="select_label"> {{item.option}} 1</text>
  38. </slot>
  39. </uv-radio>
  40. </uv-radio-group> -->
  41. <radio-group @change="change" style="width: 90%;">
  42. <Radio :selectvalue="index" :label="item.option" v-for="(item, index) in stemitem.alist" :key="index" />
  43. </radio-group>
  44. </view>
  45. <view class="donext_div">
  46. <uv-button type="primary" :text="$t('next_step')" @click="donext" :customStyle="selectbutton2" :customTextStyle="selectbutton3"></uv-button>
  47. </view>
  48. <view v-if="sindex==11&&scaleid==4" class="completedis">
  49. <text class='pregresstext'>{{$t('completion_text_1')}}</text>
  50. <text class='pregresstext'>{{$t('completion_text_2')}}</text>
  51. </view>
  52. <view class="progressarea" v-if="surplusstems<9&&surplusstems>1">
  53. <text class='pregresstext'>{{surplusstems-1}}{{$t('questions_remaining')}}</text>
  54. </view>
  55. <view>
  56. <uv-popup ref="popup" mode="bottom" @maskClick="maskClick">
  57. <view class="over_percent_div">
  58. <view class="content">
  59. <uv-text :text="stemitem.stem" align="center" size="25"></uv-text>
  60. <uv-text :text="$t('have')+percent" type="success" bold="true" align="center" size="30"></uv-text>
  61. <uv-text :text="$t('same_as_you')" align="center" size="25"></uv-text>
  62. </view>
  63. </view>
  64. </uv-popup>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import nav from "@/components/navbar.vue"
  70. import {tohome,tostemlistnext} from "/common/js/common.js"
  71. import {subanswerbyuserid} from "/common/api/scale.js"
  72. import {querypercentagebystemid} from "/common/api/health.js"
  73. import {subcomstatus} from "/common/api/scale.js"
  74. import {addlog} from "@/common/api/system.js"
  75. import Radio from "@/components/radio.vue"
  76. export default{
  77. components:{
  78. Radio
  79. },
  80. data(){
  81. return {
  82. userinfo:{},
  83. selectuser:{},
  84. stemitem:{},
  85. scaleid:0,
  86. srid:0,
  87. sindex:0,
  88. stemindexlabel:1,
  89. selectanswer:'',
  90. answeroptionid:'',
  91. customStyle:{
  92. fontSize:'30px',
  93. width:'100%',
  94. },
  95. selectbutton2:{
  96. fontSize:'30px',
  97. width:'500rpx',
  98. background:'#3f73b3',
  99. border:"0px",
  100. },
  101. selectbutton3:{
  102. fontSize:"20px",
  103. fontWeight:"bold",
  104. letterSpacing: "0.5em",
  105. },
  106. percent:0,
  107. timer:false
  108. }
  109. },
  110. computed:{
  111. surplusstems(){
  112. //剩余题目
  113. let stemlist = uni.getStorageSync('stemlist')
  114. let value = 1
  115. stemlist.map((item,index)=>{
  116. if(item.id == this.stemitem.id){
  117. value = stemlist.length - index
  118. }
  119. })
  120. return value
  121. },
  122. comstatus(){
  123. let stemlist = uni.getStorageSync('stemlist')
  124. let sindex = parseInt(this.sindex);
  125. let count = stemlist.length-2
  126. if(sindex+1 == count){
  127. return true
  128. }else{
  129. return false
  130. }
  131. }
  132. },
  133. methods:{
  134. init(){
  135. this.userinfo = uni.getStorageSync("userinfo")
  136. this.selectuser = uni.getStorageSync("selectuser")
  137. this.stemitem = uni.getStorageSync("stemitem")
  138. },
  139. change(e){
  140. //this.answeroptionid =e //old
  141. let value = e.detail.value
  142. let list = this.stemitem.alist
  143. this.selectanswer = list[value]
  144. },
  145. donext(){
  146. if(''==this.selectanswer){
  147. this.$refs.toast.show({
  148. type: 'error',
  149. message: this.$t('please_completion_problem')
  150. })
  151. return false
  152. }
  153. var answer = {
  154. userid: this.userinfo.id,
  155. fmemberid:this.selectuser.fmemberid,
  156. stemid: this.stemitem.id,
  157. answertype:1,
  158. answeroptionid: this.selectanswer.id,
  159. answeroption: this.selectanswer.option
  160. }
  161. let data={
  162. userid:this.userinfo.id,
  163. fmemberid:this.selectuser.fmemberid,
  164. srid: this.srid,
  165. scaleid: this.scaleid,
  166. }
  167. subanswerbyuserid(answer,data).then(res=>{
  168. res = res.data
  169. if(0==res.code){
  170. this.$refs.toast.show({
  171. type: 'error',
  172. message: res.errmsg
  173. })
  174. return false
  175. }
  176. if(200==res.code){
  177. uni.setStorage({
  178. key: 'srid',
  179. data: res.resultData,
  180. });
  181. let data= {
  182. stemid:this.stemitem.id,
  183. answeroptionid:this.selectanswer.id,
  184. }
  185. console.log(this.comstatus)
  186. if(this.comstatus){
  187. let srid = this.srid
  188. subcomstatus(srid).then()
  189. uni.removeStorage({
  190. key: 'stemitem',
  191. });
  192. uni.redirectTo({
  193. url: '/pages/report/report'
  194. });
  195. }else{
  196. querypercentagebystemid(data).then(res=>{
  197. res = res.data
  198. if(0==res.code){
  199. let result = tostemlistnext(this.sindex,1)
  200. if(!result){
  201. this.$refs.toast.show({
  202. type: 'error',
  203. message: this.$t('system_error')
  204. })
  205. return false
  206. }
  207. }
  208. if(200==res.code){
  209. this.percent = res.resultData+"%"
  210. this.showinfo()
  211. let that = this
  212. this.timer = setTimeout(function(){
  213. that.closeinfo()
  214. tostemlistnext(that.sindex,1)
  215. }, 3000);
  216. }
  217. })
  218. }
  219. }
  220. })
  221. },
  222. showinfo(){
  223. this.$refs.popup.open();
  224. },
  225. closeinfo(){
  226. this.$refs.popup.close();
  227. },
  228. maskClick(){
  229. clearTimeout(this.timer)
  230. this.$refs.popup.close();
  231. tostemlistnext(this.sindex,1)
  232. }
  233. },
  234. mounted() {
  235. uni.setNavigationBarTitle({
  236. title: this.$t('scale_evaluation')
  237. });
  238. this.init()
  239. },
  240. onLoad: function (option) {
  241. this.scaleid=option.scaleid
  242. this.srid=option.srid
  243. this.sindex = option.sindex
  244. },
  245. onBackPress:function(option){
  246. tohome()
  247. return true
  248. }
  249. }
  250. </script>
  251. <style scop>
  252. .titlearea{
  253. display:flex;
  254. flex-direction:column;
  255. justify-content: center;
  256. align-items:center;
  257. }
  258. .title_2{
  259. margin-top:15rpx;
  260. font-size:36rpx;
  261. font-weight:400;
  262. color:#666666
  263. }
  264. .title_member{
  265. margin-top:30rpx;
  266. font-size:36rpx;
  267. font-weight:400;
  268. color:#648EB8;
  269. }
  270. .title_desstr{
  271. width:700rpx;
  272. margin-left:25rpx;
  273. margin-top:30rpx;
  274. font-size:30rpx;
  275. font-weight:300;
  276. color:#9C9C9C;
  277. }
  278. .info_div{
  279. display: flex;
  280. flex-direction: column;
  281. align-items: center;
  282. margin-bottom: 20px;
  283. gap: 5px;
  284. margin-top: 20px;
  285. }
  286. .info_div .text_div{
  287. /* text-align: center; */
  288. letter-spacing: "0.5em";
  289. padding-left: 2em;
  290. padding-right: 2em;
  291. }
  292. .title1{
  293. color: #363636 ;
  294. font-size: 25px;
  295. font-weight: bold;
  296. text-align: center;
  297. }
  298. .title2{
  299. color: gray;
  300. font-size: 18px;
  301. text-align: left;
  302. }
  303. .select_label{
  304. margin-left: 20px;
  305. font-size: 30px;
  306. }
  307. .over_percent_div{
  308. width: 100%;
  309. height: 600rpx;
  310. display: flex;
  311. flex-direction: column;
  312. align-items: center;
  313. justify-content: center;
  314. }
  315. .over_percent_div .content{
  316. width: 80%;
  317. display: flex;
  318. flex-direction: column;
  319. align-items: center;
  320. gap: 20px;
  321. justify-content: center;
  322. }
  323. .completedis{
  324. width:750rpx;
  325. margin-bottom:15rpx;
  326. display:flex;
  327. flex-direction:column;
  328. align-items:center;
  329. }
  330. .pregresstext{
  331. width:100%;
  332. /*color:#fff;*/
  333. color:#648EB8;
  334. height:45;
  335. text-align:center;
  336. z-index:100;
  337. }
  338. .progressarea{
  339. width:750rpx;
  340. margin-bottom:5rpx;
  341. display:flex;
  342. }
  343. </style>