common.vue 7.6 KB

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