checkList.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <view>
  3. <uni-list-item :title="user.name" :note="user.note"
  4. :thumb="user.avatar" @click="showDetail(user)"
  5. thumb-size="lg" rightText="详情" showArrow clickable/>
  6. <uni-card v-show="detailModel" padding="0">
  7. <target-list-doctor v-if="targetType===3" :target="target" />
  8. <target-list-grid v-if="targetType===1" :target="target" />
  9. <target-list-riskPiont v-if="targetType===2" :target="target" />
  10. </uni-card>
  11. <uni-card padding="0" v-if="checkList&&checkList.length>0" isFull :isShadow="false">
  12. <target-list-checklist v-model="checklistId" :data="checkList" @change="changeChecklist" v-if="checkList.length>1" />
  13. <template v-if="checkList.length===1&&status===0">
  14. <uni-card isFull padding="10px 0">
  15. <p>请对本次服务进行整体评价打分</p>
  16. <view class="uni-rate-container">
  17. <uni-rate v-model="formData.score" />
  18. </view>
  19. </uni-card>
  20. <uni-card isFull padding="10px 0">
  21. <check-list-item :data="pointList" @change="changePoint" />
  22. </uni-card>
  23. <uni-card isFull padding="10px 0" v-show="appraiseAble">
  24. <appraise-form @submit="appraiseSubmit" ref="appraise-form" />
  25. </uni-card>
  26. </template>
  27. <template v-if="checkList.length===1&&status===1">已评价</template>
  28. </uni-card>
  29. <uni-drawer ref="drawePoint" mode="left" :width="290">
  30. <uni-card isFull padding="10px 0">
  31. <p>请对本次服务进行整体评价打分</p>
  32. <view class="uni-rate-container">
  33. <uni-rate v-model="formData.score" />
  34. </view>
  35. </uni-card>
  36. <uni-card isFull padding="10px 0">
  37. <check-list-item :data="pointList" @change="changePoint" />
  38. </uni-card>
  39. <uni-card isFull padding="10px 0" v-show="appraiseAble">
  40. <appraise-form @submit="appraiseSubmit" ref="appraise-form" />
  41. </uni-card>
  42. </uni-drawer>
  43. <uni-popup ref="popup-phone" type="center" :animation="false" :maskClick="false" :is-mask-click="false" class="popup-phone">
  44. <uni-card isFull padding="10px 0">
  45. <div class="popup-phone-container">
  46. <view class="title">温馨提示!</view>
  47. <view class="tip">请授权电话号码,再使用</view>
  48. <view class="popup-phone-footer">
  49. <button @click="close">取消</button>
  50. <button class="confirm" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">确认</button>
  51. </view>
  52. </div>
  53. </uni-card>
  54. </uni-popup>
  55. </view>
  56. </template>
  57. <script>
  58. import targetListDoctor from '@/components/targetListDoctor/targetListDoctor.vue'
  59. import targetListGrid from '@/components/targetListGrid.vue'
  60. import targetListRiskPiont from '@/components/riskPiont.vue'
  61. import targetListChecklist from '@/components/targetListChecklist.vue'
  62. import checkListItem from '@/components/ChecklistItem.vue'
  63. import appraiseForm from '@/components/appraise.vue'
  64. import { getByQr ,wxLogin,wxDecryptUserInfo,createChecklistRecord,getChecklistByQr} from '@/api/openApi.js'
  65. export default {
  66. data() {
  67. return {
  68. appraiseAble:false,
  69. isAuthorize:false,
  70. code:undefined,
  71. ocId:undefined,
  72. sessionKey:undefined,
  73. phoneNumber:undefined,
  74. target:"",
  75. itemList:[],
  76. checkList:[],
  77. pointList:[],
  78. detailModel:false,
  79. checklistId:undefined,
  80. pointId:undefined,
  81. targetType:undefined,
  82. targetId:undefined,
  83. piontInfo:{},
  84. status:0,
  85. user:{
  86. name:"",
  87. avatar:require('@/static/logo.png'),
  88. note:""
  89. },
  90. formData:{
  91. score:0
  92. }
  93. }
  94. },
  95. components:{
  96. targetListDoctor,
  97. targetListGrid,
  98. targetListRiskPiont,
  99. targetListChecklist,
  100. checkListItem,
  101. appraiseForm
  102. },
  103. onLoad(query) {
  104. this.init(query)
  105. },
  106. methods: {
  107. init(query){
  108. const code = decodeURIComponent(query.code) // 获取到二维码原始链接内容
  109. const ocId = decodeURIComponent(query.ocId)
  110. this.code=code
  111. this.ocId=ocId
  112. uni.clearStorageSync()
  113. uni.setStorageSync("qrcode",{
  114. code,ocId
  115. })
  116. this.showModel(ocId, code)
  117. this.login()
  118. },
  119. showModel(ocId, qrCode) {
  120. getByQr(ocId, qrCode).then((resp) => {
  121. const { code, data, msg } = resp
  122. if (code === 0) {
  123. if(!data){
  124. uni.showToast({
  125. icon:'none',
  126. title:"未获取清单信息"
  127. })
  128. return
  129. }
  130. //1-网格 3-医生
  131. let targetType=data.targetType;
  132. this.targetType=targetType
  133. this.targetId=data.targetId
  134. this.target=data.target
  135. if(targetType===3){
  136. if(data.target&&data.target.doctorAvatar){
  137. this.user.avatar=data.target.doctorAvatar;
  138. }
  139. this.user.name=data.target.doctorName;
  140. this.user.note=data.target.doctorDesc;
  141. }else if(targetType===1){
  142. this.user.name=data.target.gridTitle;
  143. this.user.note=data.target.gridDesc;
  144. }
  145. this.itemList=data.itemList
  146. this.checkList=data.checklist
  147. if(data.checklist&&data.checklist.length===1){
  148. this.changeChecklist(data.checklist[0])
  149. }
  150. }
  151. })
  152. },
  153. showDetail(user){
  154. this.detailModel=!this.detailModel
  155. },
  156. login(){
  157. let self=this;
  158. uni.getProvider({
  159. service:"oauth",
  160. success(res){
  161. let provider=res.provider
  162. uni.login({
  163. provider,
  164. success: function (loginRes) {
  165. let code=loginRes.code;
  166. wxLogin(code).then((resp)=>{
  167. const { code, data, msg } = resp
  168. if(data){
  169. if(data&&data.unionid){
  170. uni.setStorageSync('unionid',data.unionid)
  171. }
  172. self.sessionKey=data.session_key
  173. self.getUserInfo()
  174. }
  175. })
  176. }
  177. })
  178. }
  179. })
  180. },
  181. getUserInfo(){
  182. const self=this;
  183. const sessionKey=this.sessionKey;
  184. uni.showModal({
  185. title:"温馨提示!",
  186. content:"请授权使用",
  187. success(res) {
  188. if(res.confirm){
  189. self.isAuthorize=true;
  190. uni.getUserProfile({
  191. desc:"用于用户核实信息!",
  192. success(res) {
  193. const { encryptedData, iv, rawData, signature, userInfo } = res;
  194. self.userInfo=userInfo
  195. },
  196. fail(res) {
  197. self.isAuthorize=false;
  198. uni.showToast({
  199. title:"你拒绝了授权,无法使用评价功能",
  200. icon:'none',
  201. duration:2000
  202. })
  203. }
  204. })
  205. }else if(res.cancel){
  206. self.isAuthorize=false;
  207. uni.showToast({
  208. title:"你拒绝了授权,无法使用评价功能",
  209. icon:'none',
  210. duration:2000
  211. })
  212. }
  213. }
  214. })
  215. },
  216. close() {
  217. this.$refs['popup-phone'].close();
  218. this.isAuthorize=false;
  219. },
  220. getPhoneNumber(e){
  221. this.isAuthorize=true;
  222. this.$refs['popup-phone'].close();
  223. const sessionKey=this.sessionKey;
  224. const { encryptedData, iv, code} = e.detail;
  225. wxDecryptUserInfo({
  226. encryptedData, iv,sessionKey
  227. }).then((resp)=>{
  228. this.phoneNumber=resp.data&&resp.data.phoneNumber||"";
  229. })
  230. },
  231. changeChecklist(item){
  232. let qrcode=uni.getStorageSync('qrcode')
  233. if(this.checkList.length>1){
  234. if(!this.isAuthorize){
  235. uni.showToast({
  236. icon:'none',
  237. title:"未授权,不可以评价",
  238. duration:1500,
  239. })
  240. setTimeout(()=>{
  241. this.getUserInfo();
  242. },2000)
  243. return
  244. }
  245. }
  246. if(this.targetType===2){
  247. uni.setStorageSync('checklistData',{
  248. ocId:qrcode.ocId,
  249. targetId:this.targetId,
  250. checklistId:item.checklistId
  251. })
  252. uni.navigateTo({
  253. url:'/pages/riskPiont/riskPiont'
  254. })
  255. return
  256. }
  257. this.appraiseAble=true;
  258. this.checklistId=item.checklistId
  259. getChecklistByQr(qrcode.ocId,this.targetId, item.checklistId).then((resp) => {
  260. const { code, data, msg } = resp
  261. if(code===0){
  262. if(!data){
  263. uni.showToast({
  264. icon:'none',
  265. title:"未获取到清单数据"
  266. })
  267. return
  268. }
  269. if(this.checkList&&this.checkList.length>1){
  270. this.$refs.drawePoint.open()
  271. }
  272. const itemList=data.itemList;
  273. this.pointList=itemList;
  274. }
  275. })
  276. },
  277. changePoint(item){
  278. console.log({
  279. items:JSON.parse(JSON.stringify(item))
  280. })
  281. this.piontInfo=item
  282. },
  283. appraiseSubmit(data){
  284. if(!this.isAuthorize){
  285. uni.showToast({
  286. icon:'none',
  287. title:"未授权,不可以评价",
  288. duration:1500,
  289. })
  290. setTimeout(()=>{
  291. this.getUserInfo();
  292. },2000)
  293. return
  294. }
  295. const qrcode=uni.getStorageSync('qrcode');
  296. const unionid=uni.getStorageSync('unionid');
  297. const params={
  298. ocId:qrcode.ocId,
  299. wxId:unionid,
  300. wxName:this.userInfo.nickName,
  301. targetType:this.targetType,
  302. checklistId:this.checklistId,
  303. score:this.formData.score,
  304. targetId:this.targetId,
  305. ...data,
  306. pointRecordList:this.piontInfo
  307. }
  308. createChecklistRecord(params).then((resp)=>{
  309. this.$refs.drawePoint.close();
  310. this.status=1
  311. uni.showToast({
  312. icon:"success",
  313. title:"评价完成"
  314. })
  315. this.formData.score=0
  316. this.pointList=[]
  317. this.$refs['appraise-form'].reset()
  318. })
  319. }
  320. }
  321. }
  322. </script>
  323. <style lang="less" scoped>
  324. .popup-phone-container{
  325. width: 420upx;
  326. .title{
  327. font-weight: 900;
  328. font-size: 40upx;
  329. padding: 10px 0;
  330. text-align: center;
  331. }
  332. .tip{
  333. font-size: 32upx;
  334. text-align: center;
  335. }
  336. ::v-deep .popup-phone-footer{
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. padding-top: 10px;
  341. button{
  342. font-size: 16px;
  343. line-height: 2.2;
  344. }
  345. .confirm{
  346. color: #fff;
  347. background-color: #007aff !important;
  348. margin-left: 20px;
  349. }
  350. }
  351. }
  352. .popup-phone ::v-deep .uni-popup{
  353. z-index: 9999 !important;
  354. }
  355. </style>